[FWTools] edit shapefile attributes with Python
bryan at geomega.com
Thu Aug 10 10:21:51 EDT 2006
I'm simply trying to edit the attributes of a shapefile with Python. I
have no trouble creating a new shapefile, creating new features, and
adding them to the shapefile. However, now I just want to edit
attributes of the dbf. Here's my simple script:
#get the stream
ogrdriver = ogr.GetDriverByName("ESRI Shapefile")
dsRiver = ogrdriver.Open("test_py.shp")
mRiverLayer = dsRiver.GetLayerByName("test_py")
mFeature = mRiverLayer.GetFeature(0)
iIndex = mFeature.GetFieldIndex("RIVER_MILE")
which gives me this error:
ERROR 3: Error in fseek() or fwrite() writing object to .shp file.
Is attribute updating supported in shapefiles? What am I doing wrong?
Thanks for the help.
Boulder, CO, USA
More information about the FWTools