[GIS] How to calculate X and Y projected coordinate in batch processing

arcgis-desktopbatchgeometrygeoprocessing

I have more than 1000 shape files (all are point features). They were initially in WGS 84. I projected them in UTM. Then through batch processing I added X, Y fields in each table. But all the X, Y fields are now empty or rather filled with 0. I need to calculate X, Y projected coordinate through batch processing and fill newly added X, Y fields. I checked in calculate field option for batch processing under data management tool. But don't see any calculate geometry option there. Where can I find the tool in the tool box so that I can use it for batch processing all my tables to calculate X, Y in meters.
I am using ArcGIS

Best Answer

You can accomplish this in batch mode, in ModelBuilder and with Python.

Batch Mode:

  1. First delete your old XY fields using Delete Fields in batch mode. Right click on the tool and select "batch". Drag the files you want to process into the dialog box. The rows will automatically update to include all of the files you are processing.
  2. Choose the XY fields you want to delete > Fill
  3. Now add new XY fields. Search for the Add XY Coordinates (Data Management) tool in the Search tab. Right click the tool > Batch... (screenshot)
  4. Select the files you need to calculate in the Catalog and drag them over to the batch dialog box.
  5. Run the tool in batch mode. Note that the tool will automatically add an X and a Y field and calculate the coordinates.

enter image description here

Note that the can drag and drop multiple files from the highlighted section in Catalog, but only single files from the top window

enter image description here

ModelBuilder:

Same workflow as in batch mode, although it is much easier to string together commands in ModelBuilder.

enter image description here

Python

Again, the same workflow as above.

import arcpy

# The workspace where all your files are located
arcpy.env.workspace = r'C:\temp'

# Loop through the list of all your files
for fc in arcpy.ListFeatureClasses():
    arcpy.DeleteField_management (fc, ['x','y']) # Delete the old fields
    arcpy.AddXY_management (fc) # Add XY fields again and calculate coords
Related Question