Use track functions

Track functions allow you to create and evaluate Arcade expressions with track inputs in certain ArcGIS Velocity tools. Tracks are sequentially ordered features with a field specified as a track identifier (Track ID) and a Start Time field. Arcade track functions are only available when using Velocity within specific track-enabled tool expressions (Calculate Field and Map Fields).

For details on each individual track function, see Track Functions in the ArcGIS Arcade documentation.

The following track functions are available in ArcGIS Velocity:

Examples

  • Access the distance traveled from track origin to a current observation.
    • This is accomplished using the TrackCurrentDistance track function which returns the sum of distances between observations from the first to current observation.
    • This function is used such as TrackCurrentDistance(x) where x indicates the feature of inspection.
    • Example scenario:
      • A track has six features, the expression returns a value for the current feature in the track.
        • The distance from feature 1 to feature 2 is 60 meters.
        • The distance from feature 2 to feature 3 is 80 meters.
        • The distance from feature 3 to feature 4 is 30 meters.
        • The distance from feature 4 to feature 5 is 35 meters
        • The distance from feature 5 to feature 6 is 25 meters.
      • The results when feature 3 is processed would be 140 (80 + 60).
  • Access a specific field value from two observations prior to the current.
    • This is accomplished using the TrackFieldWindow track function which returns an array of attribute values from the specified field for the specified time span.
    • The function is used such as TrackFieldWindow('fieldName', startIndex, endIndex)[x]
      • fieldName: Text—The field name from which to return values.
      • startIndex: Number—The index of the beginning feature. The current feature is index 0. Positive values represent features that occur in the future, after the current value. For example, position 1 is the next value in the array. Negative numbers represent features that occurred in the past, before the current feature. For example, -1 is the previous value in the array.
      • endIndex: Number—The index of the feature at the end of the window. The current feature is index 0. Positive values represent features that occur in the future, after the current value. For example, position 1 is the next value in the array. Negative numbers represent features that occurred in the past, before the current feature. For example, -1 is the previous value in the array.
    • Example scenario:
      • Your track has a field with sequentially ordered values of [10, 20, 30, 40, 50]. The geometries of the features are [{x: 1, y: 1},{x: 2, y: 2} ,{x: null, y: null},{x: 4, y: 4}, {x: 5, y: 5}]. The expression is evaluated at each feature in the track. Results are returned inclusive of the start feature, and exclusive of the end feature. This example is evaluated at the second feature (20) and returns an array of the previous value (-1, inclusive).
      • Arcade syntax: var window = TrackFieldWindow('MyField', -2,-1)[0].
      • Result value: 10 as the [0] syntax was utilized to grab the first value from this array.
  • Access the geometry from the feature prior to the current feature.
    • This is accomplished using the TrackGeometryWindow track function which returns an array of geometries for the specified time indices.
    • This function is used such as TrackGeometryWindow(startIndex, endIndex)
      • startIndex: Number—The index of the beginning feature. The current feature is index 0. Positive values represent features that occur in the future, after the current value. For example, position 1 is the next value in the array. Negative numbers represent features that occurred in the past, before the current feature. For example, -1 is the previous value in the array.
      • endIndex: Number—The index of the feature at the end of the window. The current feature is index 0. Positive values represent features that occur in the future, after the current value. For example, position 1 is the next value in the array. Negative numbers represent features that occurred in the past, before the current feature. For example, -1 is the previous value in the array.
    • Example scenario:
      • Your track has a field with sequentially ordered values of [10, 20, 30, 40, 50]. The geometries of the features are [{x: 1, y: 1},{x: 2, y: 2} ,{x: null, y: null},{x: 4, y: 4}, {x: 5, y: 5}]. The expression is evaluated at each feature in the track. For this example, we examine results when evaluated at the third feature (30). Results are returned inclusive of the start feature, and exclusive of the end feature.
      • Arcade syntax: var window = TrackGeometryWindow(-2,2)
      • Result value: [{x: 1, y: 1},{x: 2, y: 2} ,{x: null, y: null},{x: 4, y: 4}]

Usage notes

  • The Arcade track functions are only available in the Calculate Field and Map Fields tools.
  • Real-time analytics cannot access future track values (x) as future observations have not yet entered the real-time analytic at the time of processing. Real-time analytics can only access previous (-x) and current (0) track values.
  • Previous track values can be retrieved up to 5 previous features (-5)
  • It is important when building Arcade expressions using track functions to consider what data type (array, string, number, date) is being returned by the track function, as well as your expression. Review the Track Functions documentation to see what data type is returned by each track function.

In this topic
  1. Examples
  2. Usage notes