Image Expression Type
List of mathematical and logical operators that can be employed in the logic/algebraic expression.
GUI Editor
Operators
In the syntax tables below, EXPR denotes any arbitray expression, IMAGE denotes any image identifier (a image identifier uses the syntax iX where X is an integer value from 1 to 100), TABLE denotes any table identifier (a table identifier uses the syntax tX where X is an integer value from 1 to 100) and VALUE denotes any value identifier (a value identifier uses the syntax vX where X is an integer value from 1 to 100).
During logical expressions evaluation, a zero value is supposed to be false and a non-zero value supposed to be true.
General Operators
Precedence | Operator | Description | Syntax | Usage Example |
---|---|---|---|---|
1 | Conditional | Execute the second or third term of the equation conditionally to the first | if EXPR then EXPR else EXPR | if not isNull(i1) and isNull(i2) then i3 else if isNull(i1) then i1 – i1 / i2 else (i1 – i2) |
2 | Boolean Or | The expression evaluation returns true if any of its arguments is true. See logical disjunction for additional information about the boolean logic. The evaluation is short-circuited. | EXPR or EXPR EXPR || EXPR | not isNull(i1) or isNull(i2) not isNull(i1) || isNull(i2) |
Boolean And | The expression evaluation returns true if and only if all its arguments are true. See logical conjunction for additional information about the boolean logic. The evaluation is short-circuited. | EXPR and EXPR EXPR && EXPR | not isNull(i1) and isNull(i2) not isNull(i1) && isNull(i2) |
|
3 | Equal | EXPR = EXPR EXPR == EXPR | i1 = 2 i1 == 2 |
|
Not Equal | EXPR != EXPR EXPR /= EXPR EXPR <> EXPR | i1 != 2 i1 /= 2 i1 <> 2 |
||
4 | Greater Than | EXPR > EXPR | i1 > 2 | |
Greater Than Or Equal | EXPR >= EXPR | i1 >= 2 | ||
Less Than | EXPR < EXPR | i1 < i2 | ||
Less Than Or Equal | EXPR <= EXPR | i1 <= i2 | ||
5 | Add | EXPR + EXPR | i1 + i2 | |
Subtract | EXPR – EXPR | i1 – i1 / i2 | ||
6 | Times | EXPR * EXPR | i1 * i2 | |
Divide | EXPR / EXPR | i1 / i2 | ||
Mod | EXPR % EXPR | i1 % 100 | ||
7 | Power | EXPR ^ EXPR | i1 ^ 3 | |
8 | Catch Error | Catch an algebraic error (such as division by zero, table key not found etc) and replace it with the result of another expression | EXPR ? EXPR | (i1 / i2) ? (i1 – i2) |
9 | Boolean Not | Return true, if its argument is false, and false, otherwise. See boolean negation for additional information about the boolean logic. | ! EXPR not EXPR | not isNull(i1) ! isNull(i1) |
Negate | – EXPR | – ceil(i1 + i2) |
General Functions
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Value | 2 + i1 / -3.5e-2 | ||
Random | Generate a random value using the Uniform probability distribution | rand | if rand > 0.5 then 1 else i2 |
Uniform | Generate a random value using the Uniform probability distribution. The generated value lies between the given bounds. The first EXPR represents the lower bound and the second EXPR represents the upper bound | rUniform(EXPR, EXPR) | if rUniform(12, 15) > 14 then 1 else i2 |
Normal | Generate a random value using the Normal probability distribution. The value is generated according to the first and second given EXPR representing, respectively, the mean and the deviation of the distribution | rNormal(EXPR, EXPR) | if rNormal(10, 2) > 9 then 1 else i2 |
Poisson | Generate a random value using the Poisson probability distribution. The value is generated according to the given EXPR representing the distribution lambda | rPoisson(EXPR) | if rPoisson(100) > 95 then 1 else i2 |
Square Root | Returns the square root of the expression | sqrt(EXPR) | sqrt(i1 / i4) |
Sin | Sin (input in radians) | sin(EXPR) | sin(i1 / i4) |
Cos | Cos (input in radians) | cos(EXPR) | cos(i1 + i2) |
Tan | Tan (input in radians) | tan(EXPR) | tan(i1 * i5 + 6) |
Acos | Acos (output in radians) | acos(EXPR) | acos(i1 + i2) |
Asin | Asin (output in radians) | asin(EXPR) | asin(i1 + i2) |
Atan | Atan (output in radians) | atan(EXPR) | atan(i1 + i2) |
Ceil | Convert the value to the smallest following integer | ceil(EXPR) | ceil(i1 + i2) |
Exp | Returns the natural exponential of the expression | exp(EXPR) | exp(i1[i1 + i2]) |
Floor | Convert the value to the largest previous integer | floor(EXPR) | floor(i1 + i2) |
Round | Convert the value to the nearest integer | round(EXPR) | round(i1 / i4) |
Abs | Returns the absolute value of the expression | abs(EXPR) | abs(i1 + i2) |
Ln | Returns the natural logarithm of the expression | ln(EXPR) | ln(i1 / i4) |
Log | Returns the logarithm of the expression to the base of 10 | log(EXPR) | log(i1 / i4) |
Max | Returns the maximum value | max(EXPR, EXPR) | max(i1, i2) |
Min | Returns the minimum value | min(EXPR, EXPR) | min(i1, i4) |
Signal | Return +1, if the expression is positive, -1, if it is negative, and 0, otherwise. | signal(EXPR) | signal(i1 - 4) |
Abort | Abort the model execution | abort | if i1 > 0 then i1 * i2 + 4 else abort |
Pi | Return the value of the constant Π (3.14159265358979323846) | pi | i1 * pi / 180 |
Clamp | Clamp the value to a specified range. The first EXPR represents the value that will be clamped. The second and third EXPR represent the minimum and the maximum value from the range used to clamp the given value. This function is equivalent to the following expression: if EXPR < EXPR_MIN then EXPR_MIN else if EXPR > EXPR_MAX then EXPR_MAX else EXPR | clamp(EXPR, EXPR, EXPR) | clamp(v1, 1, 12) |
ClampMod | Clamp the value to a specified range, but use the mod of the range to determine where the given value lies in. The first EXPR represents the value that will be clamped. The second and third EXPR represent the minimum and the maximum value from the range used to clamp the given value. This function is approximately equivalent to the following expression: if EXPR > EXPR_MAX or EXPR < EXPR_MIN then (EXPR - EXPR_MIN) % (EXPR_MAX - EXPR_MIN + 1) + EXPR_MIN - 1 else EXPR | clampMod(EXPR, EXPR, EXPR) | clampMod(v1, 2010, 2054) |
Value Operators
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Get Variable Value | Return the variable value | vX where X is an integer value from 1 to 100 | v1 + t1[v2 + 4] |
Image Operators and Functions
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Get Image Value | Return the image value at the current cell | IMAGE | i2 |
Get Image Value At Location | Return the image value on the specified cell coordinate. The cell coordinate is defined by two expressions where the first expression represents the cell line and the second expression represents the cell column. If the cell at that coordinate is null, the value 0 is returned. | IMAGE[ , ] | i1[line – 1, column – 2] |
Get Image Null Value | Return the null value of the current image. It is also possible to specify an image whose corresponding null value will be retrieved. The use of null without specifying an image “poisons” the expression evaluation forcing the expression result to be invalid. | null null(IMAGE) | if i1 > 2 then i1 else null if null(i2) > 2 then 1 else null |
Is Null | Return 1, if the given expression is null, and 0, otherwise. Can also be used to test whether the result of any expression is invalid or not. | isNull(EXPR) | if not isNull(i1) then i1 else i2 |
Get Line Number | Return the line number of the current cell | line | line + 1 |
Get Column Number | Return the column number of the current cell | column | if column / 2 > 50 then 1 else null |
Lookup Table Operators
Lookup table operators return the value corresponding to a given key according to a rule-operator.
They have the following syntax:
TABLE[N ]
where:
TABLE is a table identifier corresponding to a lookup table. Beware that, if the identifier is bound to a table, an error will be reported;
N is the rule-operator.
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Get Table Value | Return the table value associated with the EXPR key in the table | TABLE[EXPR] | t2[i1 + 2] |
Get Table Equal Lower Bound Value | Return the table value associated with the greater key less than or equal to the EXPR key in the table. | TABLE[<= EXPR] | t2[<= 14] |
Get Table Lower Bound Value | Return the table value associated with the greater key less than the EXPR key in the table. | TABLE[< EXPR] | t2[< i1 + 2] |
Get Table Equal Upper Bound Value | Return the table value associated with the lesser key greater than or equal to the EXPR key in the table. | TABLE[>= EXPR] | t2[>= i1 + i3] |
Get Table Upper Bound Value | Return the table value associated with lesser key greater than the EXPR key in the table. | TABLE[> EXPR] | t2[> i7] |
Get Table Closest Value | Return the table value associated with the key closest to the EXPR key in the table. | TABLE[>< EXPR] | t2[>< 3 + i7] |
Get Table Interpolaled Value | Return a linear interpolated value drawn through the neighbor keys of the EXPR key in the table. | TABLE[/ EXPR] | t2[/ i2] |
Test Table Key | Return 1, if expression corresponds to a key stored in the table, and 0, otherwise. | TABLE[? EXPR] TABLE[=? EXPR] TABLE[==? EXPR] | t2[? i2] t2[=? i2] |
Get Table Value Using Predefined Name | Return the table value bound to a key corresponding to a predefined name. This can only used to retrieve results produced by Extract Map Attributes e Extract Lookup Table Attributes. The documentation of these operators provides a list of all supported predefined names. | TABLE[“NAME”] | t2[“cellArea”] |
Table Operators
Table operators return the value corresponding to a given set of keys.
They have the following syntax:
TABLE[ [ ] [ ] ]
where:
TABLE is a table identifier corresponding to a table. Beware that, if the identifier is bound to a lookup table, an error will be reported;
The expressions representing the set of keys must be separated by commas.
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Get Table Value At Default Column | Return the table value associated with the set of keys in the first data column. | TABLE[ [EXPR, EXPR, EXPR, … ] ] | t2[ [i1 + 2, i2/2, t1[v2]] ] |
Get Table Value At Named Column | Return the table value associated with the set of keys in the column named by the given name. | TABLE[ [EXPR, EXPR, EXPR, … ] [ NAME ] ] | t2[ [i1 + 2, i2/2, t1[v2]] [ “Area_In_Hectares” ] ] |
Get Table Value At Column Index | Return the table value associated with the set of keys in the column indexed by the given expression. | TABLE[ [EXPR, EXPR, EXPR, … ] [ EXPR ] ] | t2[ [i1 + 2, i2/2, t1[v2]] [ v1+2 ] ] |
Image Neighborhood Functions
Neighborhood operators return the value of an operation within a defined neighborhood window.
They have the following syntax:
nbN(IMAGE, h, w, y, x)
where:
N is the operator name;
IMAGE is an image identifier;
h is the number of window lines;
w is the number of window columns;
y is the line where the window center is anchored at the image;
x is the column where the window center is anchored at the image.
The calculation usually includes the center of the window.
Even-sided windows have the center displaced toward the top left corner.
The window anchor (y and x) can be omitted when the window center is anchored at the current line and column. The shortened syntax is: nbN(IMAGE, h, w)
Operator | Description | Syntax | Usage Example |
---|---|---|---|
Min | Returns the minimum value of the neighbor non-null cells. | nbMin() | nbMin(i4, 2, 3, line-1, column) |
Max | Returns the maximum value of the neighbor non-null cells. | nbMax() | nbMax(i1, 4, 4) - 1 |
Sum | Returns the sum of the neighbor non-null cells. | nbSum() | nbSum(i3, 5, 5) + 7 |
Product | Returns the product of the neighbor non-null cells. | nbProd() | if not isNull(i1) then nbProd(i1, 2, 2, 0, column) else 0 |
Count | Returns the number of neighbor non-null cells. | nbCount() | nbCount(i2, 3, 3) + nbCount(i1, 3, 3, line, column+3) |
Average | Returns the arithmetic mean of the neighbor non-null cells. | nbAverage() | round(nbAverage(i1, 7, 7)) |
Median | Returns the median value of the neighbor non-null cells. For an even number of values, the greater of the two median values is returned. | nbMedian() | nbMedian(i1, 5, 5) |
Mode | Returns the mode of the neighbor non-null cells. If a mode does not exist, null is returned. If there is more than one, the lesser one is returned. | nbMode() | nbMode(i1, 5, 5) |
Variance | Returns the variance of the values of the neighbor non-null cells according to the expression: where x1, x2, …, xi are the neighbor cells; X is the mean of the neighbor cells. | nbVar() | nbVar(i4, 7, 7) / 25 |
Standard Deviation | Returns the standard deviation of the neighbor non-null cells according to the expression: where x1, x2, …, xi are the neighbor cells; X is the mean of the neighbor cells. | nbStdDev() | nbStdDev(i2, 3, 3, line+1, column) |
Image Neighborhood Indexing Functions
Neighborhood (Ref) operators finds the value of an operation within a defined neighborhood window, this value is then used as an index to retrieve data either from a table or from a secondary image.
They have the following syntax:
nbN(IMAGE, h, w, TABLE, y, x)
nbN(IMAGE, h, w, IMAGE2, y, x)
where:
N is the operator name;
IMAGE is an Image identifier;
h is the number of window lines;
w is the number of window columns;
TABLE is a LookupTable containing the values associated with each one of the Indices (Key = Index);
IMAGE2 is an Image identifier whose cell values will be returned (Cell Coordinate = Index);
y is the line where the window center is anchored at the image;
x is the column where the window center is anchored at the image.
The calculation usually includes the center of the window. Even-sided windows have the center displaced toward the top left corner.
The window anchor (y and x) can be omitted when the window center is anchored at the current line and column. The shortened syntax is: nbN(IMAGE, h, w, TABLE/IMAGE2)
Operator | Description | Syntax | Usage Example |
---|---|---|---|
MinRef | Finds the minimum value of the neighbor non-null cells. This value is then used as an Index to retrieve the resulting value from specified table or image. | nbMinRef() | nbMinRef(i4, 2, 3, t1, line, column) |
MaxRef | Finds the maximum value of the neighbor non-null cells. This value is then used as an index to retrieve the resulting value from specified table or image. | nbMaxRef() | nbMaxRef(i4, 2, 3, i1, line, column) |
There is one additional image neighborhood operator that uses a slightly different syntax:
nbConvol(IMAGE, TABLE, h, w, y, x)
where:
IMAGE is an image identifier;
TABLE is a table identifier;
h is the number of window lines;
w is the number of window columns;
y is the line where the window center is anchored at the image;
x is the column where the window center is anchored at the image.
nbConvol applies a convolution over IMAGE using the values stored on TABLE as the convolution coeficients. The table entries, from 1 to X, are mapped into the corresponding image values from top-down, left-to-right. The following examples ilustrated:
3×3 Window | ||
---|---|---|
1 | 2 | 3 |
4 | 5 | 6 |
7 | 8 | 9 |
5×5 Window | ||||
---|---|---|---|---|
1 | 2 | 3 | 4 | 5 |
6 | 7 | 8 | 9 | 10 |
11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 |
Like the previous definitions, the window anchor (y and x) can be omitted when the window center is anchored at the current line and column.
EGO Script
A image expression constant can be represented in a EGO Script using the same syntax used to represent the expression in the graphical interface editor, except that it must be surrounded by [ ]
(square brackets):
The following example illustrates:
[ if i1 <= (v3 - v1) / (v2 - v1) then v1 + sqrt(i1 * (v2 - v1) * (v3 - v1)) else v2 - sqrt((1 - i1) * (v2 - v1) * (v2 - v3)) ]