Is it possible to update an attribute field in a shapefile using pyshp ?
I went through their documentation and all they show is how to create new attribute rather than editing or updating an already existing one.
If updating is not possible, is there any other recommended Python library for doing the same ?
Answer
You can use dbfpy to directly access and edit the attributes in the shape file's dbf file.
from dbfpy import dbf
db = dbf.Dbf("your_file.dbf")
#Editing a value, assuming you want to edit the first field of the first record
rec = db[0]
rec["FIRST_FIELD"] = "New value"
rec.store()
del rec
db.close()
No comments:
Post a Comment