Skip To Content

Use expressions with GeoAnalytics Tools

There are multiple tools in the GeoAnalytics Tools toolbox that allow you to apply an expression. The following tools have the option to apply an expression:

The GeoAnalytics Tools that use expressions have different usages, as well limitations on which expressions can be applied.

Reconstruct Tracks and Create Buffers

Buffer expressions are used by the Reconstruct Tracks and Create Buffers tools.

Buffer sizes are most 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. You can perform simple as well as advanced calculations that are applied to all records. The calculation is applied to each feature that is analyzed. Calculations are performed when the analysis runs on your ArcGIS GeoAnalytics Server.

Buffer expressions can use simple calculations and all built in functions.

Buffer expression examples are included in the sections below.

Join Features

Expressions are used in the Join Features tool to specify join conditions.

In some cases, you may want to specify a condition to select features that should be included in the join. You can perform simple join conditions (such as field a > field c) as well as advanced conditions. The conditions are tested against each feature to determine what is analyzed. Calculations are performed when the analysis runs on your ArcGIS GeoAnalytics Server.

Join condition expressions can use simple calculations and advanced built in functions to create conditions. Join conditions cannot use the as_distance function. A join condition must always result in true or false.

Expression examples are included in the sections below.

Simple calculations

Simple math examples

The Reconstruct Tracks and Create Buffers tools can mathematically process numbers.

The Join Features tool can use mathematical operations when creating join conditions.

OperatorExplanationExampleResult

a + b

a plus b

["fieldname"] + 2.5

fieldname contains a value of 1.5

4.0

a - b

a minus b

["fieldname"]- 2.2

fieldname contains a value of 3.3

1.1

a * b

a multiplied by b

["fieldname"] * 2.2

fieldname contains a value of 2.0

4.4

a / b

a divided by b

["fieldname"] / 1.25

fieldname contains a value of 4.0

3.2

abs( a )

Returns the absolute (positive) value of a.

abs(["fieldname"])

fieldname contains a value of -1.5

1.5

log ( a )

Returns the natural logarithm (base e) of a.

log(["fieldname"])

fieldname contains a value of 1

0

sin ( a )

Returns the trigonometric sine of a. The input is assumed to be an angle in radians.

sin(["fieldname"])

fieldname contains a value of 1.5707

1

cos( a )

Returns the trigonometric cosine of a. The input is assumed to be an angle in radians.

cos(["fieldname"])

fieldname contains a value of 0

1

tan( a )

Returns the tangent of a. The input is assumed to be an angle in radians.

tan(["fieldname"])

fieldname contains a value of 0

0

sqrt( a )

Returns the square root of a.

sqrt(["fieldname"])

fieldname contains a value of 9

3

min( a, b )

Returns the lowest valued number between a and b.

min("fieldname", -3)

fieldname contains a value of 1.5, and a value of -3

-3

max( a, b )

Returns the highest valued number between a or b.

max("fieldname1", "fieldname2")

fieldname1 contains a value of 1.5, and fieldname2 contains a value of -3

1.5

Multiplication example for a buffer expression

["Distance"] * 2

Multiplication example for a join condition expression

["Distance"] * 2 > 5

Built-in functions for GeoAnalytics Tools

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.

The Join Features tool cannot use the as distance functions.

FunctionExplanationExampleResult

as_meters( <value> )

Applies a calculation assuming the input values are in meters.

as_meters( ["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( ["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( ["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( ["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( ["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( ["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(["Distance"]) * 3 + as_meters(10)

Advanced built-in functions for GeoAnalytics Tools buffer expressions

In addition to simple mathematical expressions, more advanced functions can be used to apply buffer expressions and join conditions.

The Reconstruct Tracks and Create Buffers tools can use advanced functions.

The Join Features tool can use advanced operations when creating join conditions.

FunctionExplanationExampleResult

constrain(<value>,<low>,<high>)

Returns the input value if it's within the constraining bounds. If the value is less than the low value, it returns the low value. If the value is greater than the high value, it returns the high value.

constrain( distance, 0, 10)

constrain(['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.

iff(<condition>,<true value>,<false value>)

Returns one value if a condition evaluates to true, and another value if that condition evaluates to false.

<true value> and <false value> can be the following:

  • A numeric field. If there is a space in the field name, use square brackets.
  • A number.
  • A function.

iff(field1 > field2, field1, 0)

iff(field1 > field2, iff(field2 = 0, field3, 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 turn, until one evaluates to true.

  • expression—An expression.
  • result—Can be a number or field.
  • default—An optional value if none of the expressions match.

when((field1 + 10) > 1, 1,(field2 + 10) > 2 , 2, 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> )

The decode function 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.

  • conditional val—Can be a field or an expression.
  • case—A value to be compared to the conditional val.
  • result—The result if the corresponding case matches the conditional val.
  • defaultValue—An optional value if no other values are true.

decode(field1 + 3 , field1, 1, 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.

Conditional statements can use the following operators:

OperatorExplanationExampleResults

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> OR <condition2>

condition one or condition two is met

(abs(-5) == 5) OR (10 > 2)

True

<condition1> AND <condition2>

condition one and condition two are met

(abs(-5) == 5) AND (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) > ["Distance"] * 2