Hi Maaza, On Wed, Sep 28, 2011 at 9:48 PM, maaza mekuria <[email protected]> wrote: > using an "ESRI Shape File" provider (instead of "ogr") in the > QgsVectorFileWriter instead of the QgsVectorLayer.
that is not the provider name, but the output format. QgsVectorLayer doesn't support to create new vector files, even Qgis uses QgsVectorFileWriter to save shapefiles (and also other vector file formats). > The parameters are ill-defined and not properly documented. The pyQGis cookbook contains snippets of code and well explained examples (e.g. how to write a shapefile using QgsVectorFileWriter [1]). Of course those are in python, but the C++ and Python API are quite the same. I recommend to have a look at the Qgis API [2], but IMHO many times the pyQGIS cookbook [3] is the best way to understand how to use some classes in your code. > Can we do something to update the documentation? Yes, you're welcome. To help us in keeping documentation updated, please look at [4]. Regards. [1] http://www.qgis.org/pyqgis-cookbook/vector.html#writing-vector-layers [2] http://doc.qgis.org/head/classes.html [3] http://www.qgis.org/pyqgis-cookbook/ [4] http://www.qgis.org/en/documentation.html > --- On Fri, 9/23/11, maaza mekuria <[email protected]> wrote: > >> From: maaza mekuria <[email protected]> >> Subject: [Qgis-developer] Vector File Creatioin >> To: "QGIS Developer" <[email protected]> >> Date: Friday, September 23, 2011, 3:50 PM >> I am wondering if I have to do to >> save the shape files. Below is the code I am using. I am >> able to create memory layers that I could save later. But I >> want to create many shapefiles and QGIS started to run out >> of memory when I was loading the memory shapefiles. Once I >> change the provider to OGR and give the path and basename, >> it gets a NULL provider. >> >> Can some of the QGIS Master's help a novice? >> >> >> QString mPath = ("c:/tmp/qgis/"); >> QString mBaseName = >> ("BikeNA"); >> QString >> provLib="ogr"; >> QgsVectorLayer* vl = 0; >> vl = new QgsVectorLayer( mPath, >> mBaseName, provLib ); >> QgsVectorDataProvider *prov = >> vl->dataProvider(); >> prov->addAttributes( >> attrList ); >> vl->startEditing(); >> QgsFeature f; >> featureList::Iterator it; >> for ( it = featureList.begin(); it != >> featureList.end();it++) >> { >> f = *it; >> vl->addFeature( f >> ); >> } >> >> vl->updateExtents(); >> vl->endEditCommand(); >> vl->commitChanges(); >> >> >> >> >> maaza >> >> _______________________________________________ >> Qgis-developer mailing list >> [email protected] >> http://lists.osgeo.org/mailman/listinfo/qgis-developer >> > _______________________________________________ > Qgis-developer mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/qgis-developer > -- Giuseppe Sucameli _______________________________________________ Qgis-developer mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-developer
