Hi All,

I have a shapefile(s) and I want to read the features, generate some metrics about each feature and then add them to the that feature. I'm using python and one obvious way to to in effect create a new shapefile with the columns I need to add, then copy the existing shapefile to the new one adding the additional metrics.

I wondering if I can add the new columns to the shapefile, then do a read and update.

Pros and cons to these approaches? and how to do the later one if possible?

I looked at the python gdal/ogr cookbook and didn't this specific example. But I thinking of something along the lines of:

1. open the dataset for read/write
2. layer.CreateField() to add the new fields
3. loop through the features in the layer
4.    and use feature.SetField()
5.    and feature = None to commit the changes

will this work?

Thanks,
  -Steve

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

_______________________________________________
gdal-dev mailing list
gdal-dev@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/gdal-dev

Reply via email to