Skip To Content

Calculate Field

Summary

Creates a new layer with calculated field values.

Usage

  • Calculate Field will always create a new 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.

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

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

    • ObjectID field
    • GlobalID field—If results are stored in the spatiotemporal data store.
    • datetime field—If results are temporally enabled. A new field, instant_datetime, for time type of instant, and new fields—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.

  • It is recommended that you use feature layers hosted on your ArcGIS Enterprise portal or use a big data file share data when running GeoAnalytics Tools in ArcGIS Pro. Other data sources may perform slowly when there are more than 1000 features.

    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:

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

Syntax

CalculateField_geoanalytics (input_layer, output_name, field_name, field_type, expression, {track_aware}, track_fields, {data_store})
ParameterExplanationData Type
input_layer

Input features that will have a field calculated.

Record Set
output_name

The name of the output feature service.

String
field_name

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

String
field_type

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

The expression used to calculate values in your 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 you are using a geographic coordinate system, 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 track-aware expressions, and a track field must be specified.
  • NOT_TRACK_AWAREThe expression does not use track-aware expressions. 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

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://sampleserver6.arcgisonline.com/arcgis/rest/services/Hurricanes/MapServer/0"
newField = "MeanSpeed3"
outFS = "HurricaneTracks_Mean"
trackIdentifier = "WINDSPEED"
calcExpression = "$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 on 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

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

Related topics