Skip To Content ArcGIS for Developers Sign In Dashboard

ArcGIS Arcade

Track Functions

GeoAnalytics Track Expressions are only available when using GeoAnalytics within specific track-enabled tools.

The following functions allow you to create and evaluate expressions with track inputs in GeoAnalytics tools. Tracks are sequentially ordered features with a field specified as a track identifier.


TrackCurrentTime - TrackDuration - TrackFieldWindow - TrackGeometryWindow - TrackIndex - TrackStartTime - TrackWindow


TrackCurrentTime

TrackCurrentTime( ) -> Date

Since version 1.7

Profiles: GeoAnalytics

Calculates the time on the current feature in a track.

Returns: Date
Example
Returns the time of the current feature being evaluated. For example, given a track with three features at January 1, 2012, December 9, 2012, and May 3, 2013 the current time will be evaluated for each feature. In this example, it's evaluated at the middle feature, December 9, 2012.
TrackCurrentTime();
// returns December 9, 2012


TrackDuration

TrackDuration( ) -> Number

Since version 1.7

Profiles: GeoAnalytics

Calculates the duration of the track from the start feature to the current feature in milliseconds from epoch.

Returns: Number
Example
Returns the duration of a track that starts on January 1, 2012 until the current feature at May 3, 2013.
TrackDuration();
// returns 42163200000


TrackFieldWindow

TrackFieldWindow( field, startIndex, endIndex ) -> Array

Since version 1.7

Profiles: GeoAnalytics

Returns an array of attribute values from the specified field for the specified time span. The window function allows you to go forward and backward in time.

Name Type Description
field String 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.
Returns: Array
Example
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).
var window = TrackFieldWindow('MyField', -1,0)
window;
// returns [10]

Your track has a field named Speed 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.
var window = TrackFieldWindow('Speed', -2,2)
window;
// returns [10,20,30,40]


TrackGeometryWindow

TrackGeometryWindow( startIndex, endIndex ) -> Geometry[]

Since version 1.7

Profiles: GeoAnalytics

Returns an array of geometries for the specified time indices. The window function allows you to go forward and backward in time.

Name Type Description
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.
Returns: Geometry[]
Example
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
var window = TrackGeomertyWindow(-2,2)
window;
// returns [{x: 1, y: 1},{x: 2, y: 2} ,{x: null, y: null},{x: 4, y: 4}]


TrackIndex

TrackIndex( ) -> Number

Since version 1.7

Profiles: GeoAnalytics

Returns the index of the feature being calculated. Features are indexed in order of time within a track.

Returns: Number
Example
Returns the index of the first feature in a track.
TrackIndex();
// returns 0


TrackStartTime

TrackStartTime( ) -> Date

Since version 1.7

Profiles: GeoAnalytics

Calculates the start time of a track.

Returns: Date
Example
Returns the start time of a track that spans from January 1, 2012 to May 3, 2013.
TrackStartTime();
// returns January 1, 2012


TrackWindow

TrackWindow( startIndex, endIndex ) -> Feature[]

Since version 1.7

Profiles: GeoAnalytics

Returns an array of features for the specified time index. This function allows you to go forward and backward in time.

Name Type Description
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.
Returns: Feature[]
Example
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 a single value -- the previous feature.
var window = TrackWindow(-1,0)
window;
// returns [{'geometry': {x: 1, y: 1}},{'attributes': {'MyField' : 10, 'trackName':'ExampleTrack1'}}]

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.
var window = TrackWindow(-2,2)
window;
// returns [{'geometry': {x: 1, y: 1},{x: 2, y: 2} ,{x: null, y: null},{x: 4, y: 4}},{'attributes': {'MyField' : 10, 'trackName':'ExampleTrack1'},{'MyField' : 20, 'trackName':'ExampleTrack1'},{'MyField' : 30, 'trackName':'ExampleTrack1'},{'MyField' : 40, 'trackName':'ExampleTrack1'}]



Feedback on this topic?