Calculate Field (GeoAnalytics Desktop)

Summary

Creates a layer with calculated field values.

Usage

  • Calculate Field is completed on tables or point, line, or polygon features.

  • Calculate Field will always create a layer. It will not modify the input. You can only calculate values for a single field at a time.

  • You can calculate values for an existing field or for a new field you add 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 and of time type instant and that a track field is specified. To learn more about building track-aware expressions, see Track aware examples.

  • To include a track-aware calculation, you must do the following:

    • Use a layer that is time enabled and of time type instant.
    • Check the Track Aware check box.
    • Select the fields used to identify tracks.

  • Tracks are represented by the unique combination of one or more track fields. For example, if the flightID and Destination fields are used as track identifiers, the features ID007, Solden and ID007, Tokyo would be in two separate tracks, since they have different values for the Destination field.

  • Similar analysis can also be completed using the following:

  • Applying a time interval boundary segments tracks at a defined interval. For example, if you set the time interval boundary to 1 day, starting at 9:00 a.m on January 1, 1990, each track will be truncated at 9:00 a.m. every day and analyzed within that segment. This split is accelerates computing time, as it creates smaller tracks for analysis. If splitting by a recurring time interval boundary makes sense for your analysis, it is recommended for big data processing. Your analysis must be track aware to set a time boundary.

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

    • ObjectID
    • datetime—If results are temporally enabled. The new fields are instant_date for time type instant, and start_date and end_date for time type interval.

  • You can improve performance of the Calculate Field tool by doing one or more of the following:

    • Set the extent environment so that you only analyze data of interest.
    • If you are using tracks, split your tracks using the Time Boundary Split parameter.
    • Only select Track Aware if your expression includes a track expression.
    • Use data that is local to where the analysis is being run.

  • This geoprocessing tool is powered by Spark. Analysis is completed on your desktop machine using multiple cores in parallel. See Considerations for GeoAnalytics Desktop tools to learn more about running analysis.

  • 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 ArcGIS GeoAnalytics Server. If your data isn't local, it will take longer to run a tool. To use your ArcGIS GeoAnalytics Server to perform analysis, see GeoAnalytics Tools.

Syntax

arcpy.gapro.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 whether values will be calculated for a newly created field or an existing field.

  • NEW_FIELDValues will be calculated for a newly created field.
  • EXISTING_FIELDValues will be calculated for an existing field.
String
field_name
(Optional)

The new field that will have values calculated.

String
existing_field
(Optional)

The 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 you are using a geographic coordinate system, in which case they will be in meters.

Calculator Expression
track_aware
(Optional)

Specifies whether the expression will use a track-aware expression.

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

One or more fields that will be used to identify unique tracks.

Field
time_boundary_split
(Optional)

A time span to split the 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 January 1, 1980, tracks will be split at the beginning of every day.

Time Unit
time_boundary_reference
(Optional)

The reference time used to split the input data into for analysis. Time boundaries will be created for the entire span of the data, and the reference time does not need to occur at the start. If no reference time is specified, 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