Skip To Content

Calculate Field

Summary

Creates a layer with calculated field values.

Usage

  • This geoprocessing tool is available with ArcGIS Enterprise 10.6 or later.

  • 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.

    Learn more about GeoAnalytics Server Arcade expressions with Calculate Field

  • 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.

  • In addition to the calculated field, the output may include the following new field types:

    • ObjectID
    • GlobalID—If results are stored in the spatiotemporal data store.
    • datetime—If results are temporally enabled. The new fields are instant_datetime, for time type of instant, and start_datetime and end_datetime, for time types of interval.

  • This geoprocessing tool is powered by ArcGIS GeoAnalytics Server. Analysis is completed on your GeoAnalytics Server, and results are stored in your content in ArcGIS Enterprise.

  • When running GeoAnalytics Server Tools, the analysis is completed on the GeoAnalytics Server. For optimal performance, data should be available to the GeoAnalytics Server through feature layers hosted on your ArcGIS Enterprise portal or through big data file shares. Data that is not local to your GeoAnalytics Server will be moved to your GeoAnalytics Server before analysis begins. This means that it will take longer to run a tool, and in some cases, moving the data from ArcGIS Pro to your GeoAnalytics Server may fail. The threshold for failure depends on your network speeds, as well as the size and complexity of the data. Therefore, it is recommended that you always share your data or create a big data file share.

    Learn more about sharing data to your portal

    Learn more about creating a big data file share through Server Manager

  • Similar analysis can also be completed using the following:

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

Syntax

CalculateField(input_layer, output_name, field_name, field_type, expression, {track_aware}, track_fields, {data_store}, {time_boundary_split}, {time_boundary_reference})
ParameterExplanationData Type
input_layer

The input features that will have a field calculated.

Record Set
output_name

The name of the output feature service.

String
field_name

The name of the field that will have values calculated. This can be an existing field or a new field name.

String
field_type

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
data_store
(Optional)

Specifies the ArcGIS Data Store where the output will be saved. The default is SPATIOTEMPORAL_DATA_STORE. All results stored to the SPATIOTEMPORAL_DATA_STORE will be stored in WGS84. Results stored in a RELATIONAL_DATA_STORE will maintain their coordinate system.

  • SPATIOTEMPORAL_DATA_STOREOutput will be stored in a spatiotemporal big data store. This is the default.
  • RELATIONAL_DATA_STOREOutput will be stored in a relational data store.
String
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, starting on January 1, 1980 tracks will be will be split at the beginning of every day. This parameter is only available with ArcGIS Enterprise 10.7 and later.

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. This parameter is only available with ArcGIS Enterprise 10.7 and later.

Date

Derived Output

NameExplanationData Type
output_table

The new output with calculated values.

Record Set

Code sample

Calculate Field example 1 (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

# Requirements: ArcGIS GeoAnalytics Server

# Import system modules
import arcpy

# Set local variables
inFeatures = "https://example.arcgis.com/arcgis/rest/services/Hurricanes/FeatureServer/0"
newField = "MeanSpeed3"
outFS = "HurricaneTracks_Mean"
trackIdentifier = "Name"
calcExpression = "Average($track.field['WINDSPEED'].history(-3))"

# Execute Reconstruct Tracks
arcpy.geoanalytics.CalculateField(inFeatures, outFS, newField, "Double", 
                                  calcExpression, True, trackIdentifier)

Environments

Output Coordinate System

The coordinate system that will be used for analysis. Analysis will be completed in the input coordinate system unless specified by this parameter. For GeoAnalytics Tools, final results will be stored in the spatiotemporal data store in WGS84.

Licensing information

  • Basic: Requires ArcGIS GeoAnalytics Server
  • Standard: Requires ArcGIS GeoAnalytics Server
  • Advanced: Requires ArcGIS GeoAnalytics Server

Related topics