Skip To Content

Calculate Field

Summary

Creates a layer with calculated field values.

Usage

  • Calculate Field will always create a layer. It will not modify the input.

  • You can calculate values for a field that already exists or add a new field by creating a unique field name.

  • Expressions are created using Arcade expressions. See Arcade Expressions in GeoAnalytics Desktop tools for more information.

  • Arcade expressions can be track aware. Track-aware expressions require that data is time enabled of time type instant and that a track field is specified. To learn more about building track-aware expressions, see Track aware examples.

  • Similar analysis can also be completed using the following:

    • ArcGIS Pro Calculate Field geoprocessing tool in the Data Management toolbox.

  • This geoprocessing tool is powered by Spark. Analysis is completed on your desktop machine using multiple cores in parallel.

  • When running GeoAnalytics Desktop Tools, the analysis is completed on your desktop machine. For optimal performance, data should be available on your desktop. If you are using a hosted feature layer, it is recommended that you use GeoAnalytics Server. If your data isn't local, it will take longer to run a tool. If you want to use your GeoAnalytics Server to perform analysis, see GeoAnalytics Server tools.

Syntax

CalculateField(input_layer, output, field_to_calculate, {field_name}, {existing_field}, {field_type}, expression, {track_aware}, track_fields, {time_boundary_split}, {time_boundary_reference})
ParameterExplanationData Type
input_layer

The input features that will have a field calculated.

Table View
output

A new dataset with calculated fields.

Feature Class;Table
field_to_calculate

Specifies if you would like to create a new field or modify an existing field.

  • NEW_FIELD Create a new field and calculate values.
  • EXISTING_FIELD Calculate values for an existing field.
String
field_name
(Optional)

The new field that will have values calculated.

String
existing_field
(Optional)

An existing field that will have values calculated.

Field
field_type
(Optional)

Specifies the field type for the calculated field.

  • STRINGThe new field will be of type text.
  • INTEGER The new field will be of type integer.
  • FLOAT The new field will be of type float.
  • DATE The new field will be of type date.
String
expression

Calculates values in the field. Expressions are written in Arcade and can include operators and multiple fields. Calculated values are applied in the units of the spatial reference of the input, unless a geographic coordinate system is used, in which case they will be in meters.

Calculator Expression
track_aware
(Optional)

Specifies whether the expression uses a track-aware expression.

  • TRACK_AWAREThe expression uses a track-aware expression, and a track field must be specified.
  • NOT_TRACK_AWAREThe expression does not use a track-aware expression. This is the default.
Boolean
track_fields
[track_fields,...]

One or more fields used to identify unique tracks.

Field
time_boundary_split
(Optional)

A time span to split your input data into for analysis. A time boundary allows you to analyze values within a defined time span. For example, if you use a time boundary of 1 day, and set the time boundary reference to be January 1, 1980 tracks will be will be split at the beginning of every day.

Time Unit
time_boundary_reference
(Optional)

The reference time used to split your input data into for analysis. Time boundaries will be created for the whole span of the data, and the reference time does not need to occur at the start. If no reference time is used, January 1, 1970 is used.

Date

Code sample

Calculate Field example (Python window)

The following Python window script demonstrates how to use the CalculateField tool.

#-------------------------------------------------------------------------------
# Name: CalculateField.py
# Description: Calculate the mean of the 3 most recent speed measurements in hurricane tracks

# Import system modules
import arcpy

arcpy.env.workspace = "C:/data/Weather.gdb"

# Set local variables
inFeatures = "Hurricanes"
fieldName = "MeanSpeed3"
out = "HurricaneTracks_Mean"
calcExpression = "Date($feature.DateAsString)"
# Execute Calculate Field
arcpy.gapro.CalculateField(inFeatures, out, "NEW_FIELD", fieldName, "", "Date", 
                           calcExpression)

Licensing information

  • Basic: No
  • Standard: No
  • Advanced: Yes

Related topics