[gdal-dev] Question about adding features to ESRI Shapefile without Geometry

Even Rouault even.rouault at mines-paris.org
Wed Jul 25 13:22:52 PDT 2012


Le mercredi 25 juillet 2012 22:09:32, Sebastian D'Agostino a écrit :
> Hi Even,
> 
> Thank you very much for your reply.
> 
> I couldn't provide code for my question because it isn't standalone code
> (I'm using a couple of classes in a big C++ project).

Yes my suggestion was that you try to isolate the few lines of codes that are 
spread among your big project into something small and standalone so that 
people you are asking the question have a chance to investigate ;-)

> Besides, I'm doing it in the reverse order:
> lyr.CreateFeature(feat)
> feat.SetGeometry(None)

Ah, that won't work ! Any change you make on the feature after calling 
CreateFeature() will not be saved into the shapefile. You need to do it before. 
Or if you do it afterwards, you'll need to call lyr.SetFeature(feat) to update 
the on-file content (but if you can set the feature completely before calling 
CreateFeature(), that will be more efficient of course)


More information about the gdal-dev mailing list