Adding & Calculating Fields in an Attribute Table

Included in this tutorial

  • Accessing and using the Add Field tool in ArcGIS Pro

  • Accessing and using the Calculate Field tool in ArcGIS Pro

Software version in examples: ArcGIS Pro 2.8.2

Tutorial Data: The tutorial includes demonstration with sample data available here.

Credits: L. Meisterlin with Moses Levich, Thiago Lee, and Erik Strand (2021).

 

Adding New Fields

There are several ways to add a new, empty field to the Attribute Table of a feature class.

Four Options:

  1. Click on the Add button on top of the Attribute Table. Specify a name, data type, and other properties (This method is demonstrated below.)

  2. In the Main Menu Ribbon, click on the contextual tab View (visible when an Attribute Table is open) > Add Field.

  3. Click the prompt at the bottom of the Fields view of a Table, which reads “Click here to add a new field.”

  4. Create a new field when you calculate its values using the Calculate Field tool (covered in the next section).

adding a new empty text field, called “NewText”, from within the Attribute Table

REMINDER: When adding a field, you will need to specify its data type.

 

Calculating Field Values

Calculate values in an existing or new attribute table field using the Calculate Field tool. There are several options for accessing this tool.

Three Options:

  1. Access the tool directly through the button Calculate in the attribute table. (This option is demonstrated below.)

  2. The Calculate Field tool can also be accessed (like any other tool) through Geoprocessing toolboxes, under Data Management Tools > Fields > Calculate field.

  3. You can also search for the tool in the Geoprocessing search bar.

accessing the Calculate Field tool through the Attribute Table

Field Calculations and the Tool Dialogue Box

Field calculations in ArcGIS Pro can be performed with Python expressions. Simple expressions can be typed directly into the Expression text box, while more complex functions may require the use of a Code Block.

The basic outline of the dialogue box and its inputs are described below. A growing list of field calculation helpers that require code blocks can be found at Common Field Calculations.

The inputs of the Calculate Field tool include…

  • Input Table: the relevant (attribute) table for the calculated field. This is required.

  • Field Name (existing or new): If you are calculating values in an existing field within your input table, choose it from the drop-down list of fields. Alternatively, type a new field name into this text box to create a new field. This is required.

    • If a new field, then you will also be prompted to specify the new field’s data type.

  • Expression Type: Choose the language with which you will write the expression for your new values. The default is Python 3. This is required.

  • The Expression section of the dialogue box includes standard tools and choices as well as empty text boxes. The only required element of the Expression section of the tool is the Expression textbox.

    • Fields: This is a list of the fields within the Input Table. You can double-click these to add them to your expression.

    • Helpers: This is a list of operators and commands that might be useful in constructing the field expression. These, too, can be added to your expression by double-clicking.

    • Beneath the Fields list is an Insert Values drop-down that allows you to access specific values from a field selected in the Fields list.

    • Beneath the Helpers list is a small collection of the most common, familiar operator buttons. These include + addition, - subtraction, * multiplication, / division, and = equality. You can click each of these to add the operator to your expression.

    • The Expression textbox follows the heading “Field Name =” (where “Field Name” is the field specified in the Field Name (existing or new) option. Thus, we can read this as “Field Name = expression.” This is required.

    • The Code Block textbox allows you to use Python (if the default expression type is used) to create a more complex expression. This is not required for executing

    • Additionally, note that the dialogue box includes buttons that allow you to save or load code blocks.

  • As with other tools, both the Apply and OK buttons will execute the tool.

 
Previous
Previous

Calculating Percent Difference

Next
Next

Calculating Proportion (& other simple calculations)