Skip to content

Instantly share code, notes, and snippets.

@glw
Last active August 29, 2015 14:02
Show Gist options
  • Save glw/20483fd5d7f0ac9caa8c to your computer and use it in GitHub Desktop.
Save glw/20483fd5d7f0ac9caa8c to your computer and use it in GitHub Desktop.
Arcpy batch field calculation
import arcpy
mxd = arcpy.mapping.MapDocument("Current") # finds metadata on your current MXD
layerlist = arcpy.mapping.ListLayers(mxd) # grabs a list of layers with in your MXD
del layerlist[3] #If you need to delete an item in the layerlist list
expr = "'Northwest'" # Variables to run the calculatefield function. **notice the extra '' within ""...
field = "Zone" #
# Goes through list and assigns expr to the field you specified
for l in layerlist: arcpy.CalculateField_management(l,field,expr,"PYTHON_9.3","#")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment