Wednesday 21 September 2016

How to add attribute field to existing Shapefile via Python without ArcGIS?



I have a Python script that adds an attribute field to a Shapefile if doesn't exist. This is easy to do with ArcGIS (graphically or via Python), but I'm looking for something that doesn't depend on ArcGIS.


I tried this unsuccessfully with OGR, since my Shapefile contains features.


I've looked at pyshp, but similarly there is no way to modify the schema after it has been created. I haven't had a try with shapefile (for Python), but I don't see this feature advertised. I also can't see how this can be done by tinkering with the DBF file via dbfpy.


Does anyone have any ideas?



Answer



you should have a look on these questions since it has been answered already : How to add custom Feature attributes to Shapefile using Python?


https://stackoverflow.com/questions/4215658/adding-custom-feature-attributes-to-esri-shapefile-with-python


If you want as result, only one shapefile, just delete your input files at the end of your script.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...