0

I have a folder and inside of that folder, I have about 500 sub folders which contain on average about 5 shapefiles each.

What I want to do is:

  • to check if there is a field, lets say field_1, and if it is not in the attribute table, to add it (TEXT length = 6) and then
  • to reproject all the shapefiles preferably with ogr2org to EPSG:3035

I find this question 1 but my data are in multiple directories and this question 2 which is for converting all shapefiles in a directory.

the above questions give me food for thought of how can someone do something that I am looking for.

  • 1
    Would you be able to edit your question to include a code snippet to show what you have tried and where you are stuck, please? – PolyGeo Aug 10 '15 at 12:38
1

Here is the arcpy/python script flow:

  1. Use os.walk to iterate through directory and sub-directories
  2. Once shp is found use ListFields function to get a list of all shp field names
  3. Use condition if logic to check if field name exists in fc from ListFields list
  4. If field name does not exist use Add Field method to create the field
  5. Use Project method to re-project shp
  • 1
    If using ArcGIS 10.1 SP1 or later I would recommend using arcpy.da.Walk over os.walk. – PolyGeo Aug 10 '15 at 21:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.