Masthead

Using Python in the Field Calculator

Using Python to Compute Field Values

You can use Python to create much more complex operations in the Field Calculator than you can normally enter.

  1. Open the Field Calculator in ArcMap
  2. Switch the "Parser" to "Python"
  3. Check "Show Code block
  4. Create a Python function in the "Pre-Logic Script Code:" section. Make the function return a value that will be placed in the attribute
  5. In the section at the bottom of the dialog, create a function that calls you function in the "Pre-Logic" section. Double click on the attribute you want to send into the function and you'll see ArcMap adds exclamation points on either side of the attribute name. This tells ArcMap to replace the attribute name, and the exclamation points, with the values for each of the attributes.

Image of the field calculator with a Python function being used to set the values in the field.

Contributed by Lindsey Holm

© Copyright 2018 HSU - All rights reserved.