[gdal-dev] python ogr feature didn't save attributes

Even Rouault even.rouault at spatialys.com
Tue Jun 23 07:02:25 PDT 2015


Luca,

> 
> I'm writing a function to cycle inside the feature and update a column
> of attribute table, if I print the feature with DumpReadable() I can
> see the right attributes but when the script finish the final
> shapefile has no attribute table, any idea?
> 
> This is the relevant part of code
> 
> featureDefn = lay0.GetLayerDefn()
> field = ogr.FieldDefn(out_col, ogr.OFTReal)
> featureDefn.AddFieldDefn(field)

As suggested in http://gdal.org/python/osgeo.ogr.FeatureDefn-
class.html#AddFieldDefn , you must call CreateField() on the layer object 
instead.

Even

-- 
Spatialys - Geospatial professional services
http://www.spatialys.com


More information about the gdal-dev mailing list