[Qgis-developer] Vector File Creatioin

maaza mekuria sailmcm at yahoo.com
Fri Sep 23 20:47:28 EDT 2011


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



More information about the Qgis-developer mailing list