Skip to content

Instantly share code, notes, and snippets.

@maphew
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maphew/fabd3e2562e943778d0c to your computer and use it in GitHub Desktop.
Save maphew/fabd3e2562e943778d0c to your computer and use it in GitHub Desktop.
#calculate new field 'summed' in feature class 'test'
inFeatures='test'
fieldName01='summed'
exSummed = "stack(!field01!+!field02!+!field03!)"
codeBlock = '''
def stack(*args):
return sum(filter(None, args))
'''
arcpy.CalculateField_management(inFeatures, fieldName01, exSummed, "PYTHON", codeBlock)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment