The following tools in the GeoAnalytics Tools toolbox allow you to apply an expression:
- Create Buffers for buffer expressions.
- Reconstruct Tracks for buffer expressions.
- Join Features for join conditions.
- Detect Incidents for incident conditions.
- Calculate Field to calculate field values.
The GeoAnalytics Tools that use expressions have different purposes, as well as limitations on the expressions that can be applied. At ArcGIS 10.6, all expressions used in GeoAnalytics support Arcade.
Learn more about Arcade functions
Reconstruct Tracks and Create Buffers
Buffer expressions are used by the Reconstruct Tracks and Create Buffers tools.
Buffer sizes are commonly entered using constant or field values. However, entering values is not the only way you can specify a buffer size using GeoAnalytics Tools. In some cases, you may want to perform a mathematical calculation to set the buffer size. The calculation is applied to each analyzed feature. Calculations are performed when the analysis runs on your ArcGIS GeoAnalytics Server.
Buffer expression examples are included in the following sections.
Mathematical operator and function examples
Buffer expressions mathematically process numbers. The following table shows a sample of available operations.
Learn more about mathematical operations and functions available in Arcade
Operator | Explanation | Example | Result |
---|---|---|---|
a + b | a plus b. | fieldname contains a value of 1.5 $feature["fieldname"] + 2.5 | 4.0 |
a - b | a minus b. | fieldname contains a value of 3.3 $feature["fieldname"]- 2.2 | 1.1 |
a * b | a times b. | fieldname contains a value of 2.0 $feature["fieldname"] * 2.2 | 4.4 |
a / b | a divided by b. | fieldname contains a value of 4.0 $feature["fieldname"] / 1.25 | 3.2 |
abs( a ) | Returns the absolute (positive) value of a. | fieldname contains a value of -1.5 abs($feature["fieldname"]) | 1.5 |
log( a ) | Returns the natural logarithm (base E) of a. | fieldname contains a value of 1 log($feature["fieldname"]) | 0 |
sin( a ) | Returns the trigonometric sine of a. The input is assumed to be an angle in radians. | fieldname contains a value of 1.5707 sin($feature["fieldname"]) | 1 |
cos( a ) | Returns the trigonometric cosine of a. The input is assumed to be an angle in radians. | fieldname contains a value of 0 cos($feature["fieldname"]) | 1 |
tan( a ) | Returns the tangent of a. The input is assumed to be an angle in radians. | fieldname contains a value of 0 tan($feature["fieldname"]) | 0 |
sqrt( a ) | Returns the square root of a. | fieldname contains a value of 9 sqrt($feature["fieldname"]) | 3 |
min( a, b ) | Returns the lowest-valued number between a and b. | fieldname contains a value of 1.5, and a value of -3 min($feature["fieldname"], -3) | -3 |
max( a, b ) | Returns the highest-valued number between a or b. | fieldname1 contains a value of 1.5, and fieldname2 contains a value of -3 max($feature["fieldname1"], $feature["fieldname2"]) | 1.5 |
constrain(<value>,<low>,<high>) | Returns the input value if it's within the constraining bounds. If the input value is less than the low value, it returns the low value. If the input value is greater than the high value, it returns the high value. | constrain($feature["distance"], 0, 10) constrain($feature['Store dist'], 6, distance) | Returns 0 if distance is less than 0, 10 if distance is greater than 10, and distance otherwise. Returns 6 if Store dist is less than 6, distance if Store dist is greater than distance, and Store dist otherwise. |
Multiplication example for a buffer expression
$feature["Distance"] * 2
As distance function examples
The as distance functions cast numeric values to a linear distance, which can then be used in a mathematical expression. The Reconstruct Tracks and Create Buffers tools can use as distance functions. If a numeric value is used without an as distance function, the unit is assumed to be meters.
Function | Explanation | Example | Result |
---|---|---|---|
as_meters( <value> ) | Applies a calculation assuming the input values are in meters. | as_meters( $feature["fieldname"] ) as_meters(150) | Results are buffered by 150 meters. |
as_kilometers( <value> ) | Applies a calculation assuming the input values are in kilometers. | as_kilometers( $feature["fieldname"] ) as_kilometers(150) | Results are buffered by 150 kilometers. |
as_feet( <value> ) | Applies a calculation assuming the input values are in feet. | as_feet( $feature["fieldname"] ) as_feet(150) | Results are buffered by 150 feet. |
as_yards( <value> ) | Applies a calculation assuming the input values are in yards. | as_yards( $feature["fieldname"] ) as_yards(150) | Results are buffered by 150 yards. |
as_nautical_miles( <value> ) | Applies a calculation assuming the input values are in nautical miles. | as_nautical_miles( $feature["fieldname"] ) as_nautical_miles(150) | Results are buffered by 150 nautical miles. |
as_miles( <value> ) | Applies a calculation assuming the input values are in miles. | as_miles( $feature["fieldname"] ) as_miles(150) | Results are buffered by 150 miles. |
For each feature, multiply the field Distance, assuming it's in kilometers, and add 10 meters for a buffer expression.
as_kilometers($feature["Distance"]) * 3 + as_meters(10)
Conditional operators
Conditional statements can use the following operators:
Operator | Explanation | Example | Results |
---|---|---|---|
a > b a < b | a is greater than b a is less than b | 10 > 2 | False |
a >= b a <= b | a is greater than or equal to b a is less than or equal to b | abs(-10) >= 10 | True |
a != b | a is not equal to b | abs(-3) != -3 | True |
a == b | a is equal to b | abs(-5) == 5 | True |
<condition1> || <condition2> | Condition 1 or condition 2 is met. | (abs(-5) == 5) || (10 < 2) | True |
<condition1> && <condition2> | Condition 1 and condition 2 are met. | (abs(-5) == 5) && (10 < 2) | False |
Example of a buffer expression using advanced functions and conditions
iff(field1 > field2, iff(field2 = 0, field3, field4), 0)
Multiplication example for join condition
iff(field1 > field2, iff(field2 = 0, field3, field4), 0) > $join["Distance"] * 2
Logical operator examples
In addition to the conditional operators, more advanced logical operators can be used to create buffers as shown in the following table.
Learn more about the logical functions available in Arcade
Function | Explanation | Example | Result |
---|---|---|---|
iff(<condition>,<true value>,<false value>) | Returns one value if a condition evaluates to true and returns another value if that condition evaluates to false. <true value> and <false value> can be the following:
| iff($feature["field1"] > $feature["field2"], $feature["field1"], 0) iff($feature["field1"] > $feature["field2"], iff($feature["field2"] = 0, $feature["field3"], $feature["field4"]), 0) | Returns field1 if field1 is greater than field2, and 0 otherwise. Returns the result of the second iff function if field1 is greater than field2, and 0 otherwise. |
when(<expression1> , <result1> , <expression2> , <result2> , ... , <expressionN> , <resultN>, <default>) | Evaluates a series of expressions in order until one evaluates to true.
| when(($feature["field1"] + 10) > 1, 1,($feature["field2"] + 10) > 2 , 2, $feature["field3"]) | If field1 + 10 is greater than 1, returns 1. If not, checks if field2 + 10 is greater than 2. If yes, it returns 2. If not, it returns field3. |
decode(<conditional val> , <case1> , <result1>, <case2>, <result2>, ... <caseN>, <resultN>, <defaultValue> ) | Evaluates an expression and compares its value with subsequent parameters. If the expression matches, it returns the next parameter value. If none match, there is the option for the last parameter to be a default return value.
| decode($feature["field1"] + 3 , $feature["field1"], 1, $feature["field2"], 2, 0) | Compares equality between the conditional val field1 + 3 and case1 field1. If true, it returns 1. If false, it compares the equality between field1 + 3 and field2. If true, it returns 2; otherwise, it returns 0. |
Track aware examples
Reconstruct Tracks can use track-aware equations in Arcade as shown in the following table:
Function | Explanation | Example | Result | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
TrackStartTime() | Calculates the start time of a track in milliseconds from epoch. | Using a track that starts on January 2, 2017 TrackStartTime() | 1483315200000 | ||||||||||||
TrackDuration() | Calculates the duration of a track in milliseconds from the start until the current time step. | Using a track that starts on January 2, 2017, and the current time is January 4, 2017. TrackDuration() | 172800000 | ||||||||||||
TrackCurrentTime() | Calculates the current time in a track. | Using a feature that occurs on January 3, 2017, at 9:00 a.m. TrackCurrentTime() | 1483434000000 | ||||||||||||
TrackIndex | Returns the time index of the feature being calculated. | Calculating this value on the first feature in a track. TrackIndex | 0 | ||||||||||||
TrackFieldWindow(<fieldName>, <startIndex>, <endIndex>) | Returns an array of values in the given field for the specified time index. The window function allows you to go forward and backward in time. The expression is evaluated at each feature in the track.
| MyField has sequentially ordered values of [10, 20, 30, 40, 50]. The expression is evaluated at each feature in the track. Results are returned inclusive of the start feature, and exclusive of the end feature. Example 1:TrackFieldWindow("MyField,-1,2) Example 2:TrackFieldWindow("MyField,-2,0)[0] Example 3:TrackFieldWindow("MyField,0,3)[2] | Example 1: When evaluated at each feature, the table shows the following results.
Example 2: When evaluated at index 2 (value is 30), it returns: 10. Example 3: When evaluated at index 2 (value is 30), it returns: 50. | ||||||||||||
TrackGeometryWindow(<startIndex>, <endIndex>) | Returns an array of values representing geometry for the specified time index. The window function allows you to go forward and backward in time. The expression is evaluated at each feature in the track.
| MyField has sequentially ordered values of [10, 20, 30, 40, 50]. The geometry 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. Example 1:TrackGeometryWindow(-1,2) Example 2: TrackGeometryWindow(0,1)[0] on a polyline dataset Example 3: TrackGeometryWindow(0,1)[0] on a polygon dataset Example 4: Find the X value of the previous point TrackGeometryWindow(-1,0)[0]["x"] | Example 1: When evaluated at each feature, the table shows the following results.
Example 2: Polylines are returned in the following format: [{"paths":[[[-180,-22.88],[-177.6,-23.6]],[[180,-18.099999999999994],[179.7,-18.4],[179.4,-18.7],[178.9,-18.9],[178.5,-19.3],[178.2,-19.7],[178.4,-20],[178.8,-20.2],[178.9,-21.8],[179,-22.2],[179.4,-22.7],[180,-22.88]],[[-178,-17],[-178.8,-17.3],[-179.2,-17.5],[-179.6,-17.8],[-179.9,-18],[-180,-18.099999999999994]]]}] Example 3: Polygons are returned in the following format: [{"rings":[[[-7882559.1197999995,6376090.883500002],[-7893142.474300001,6042715.216800004],[-8544018.775999999,6045361.0554000065],[-8544018.775999999,6376090.883500002],[-7882559.1197999995,6376090.883500002]]]}] Example 4: Evaluated at index 2 (value is 30): 2 | ||||||||||||
TrackWindow(<value1>, <value2>) | Returns an array of values representing geometry and all attributes for the specified time index. The window function allows you to go forward and backward in time.
| MyField has sequentially ordered values of [10, 20, 30, 40, 50], in addition to the objectID, globalID and instant_datetime fields. The geometry 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. Example 1:TrackWindow(-1,0)[0] Example 2:geometry(TrackWindow(-1,0)[0]["x"] | Example 1: When evaluated at each feature, the table shows the following results.
Example 2: Evaluated at index 2 (value is 30): 2 |