This is an old revision of the document!


PHP's gd library is missing or unable to create PNG images

Calculate Map

Description

This container calculates a map using algebraic/logical expression involving maps, tables and values.

Inputs

Name Type Description
Expression Image Expression Algebraic or logical expression used to calculate the output map.

Optional Inputs

Name Type Description Default Value
Cell Type Cell Type Data cell type Signed 32 Bit Integer
Null Value Int Null value -2147483648
Result Is Sparse Bool If true, the resulting map is created as a sparse image. Sparse images have the advantage of storing only the cells containing non-null values, but they have diminished access time. False

Outputs

Name Type Description
Result Map Output map.

Group

Notes

The expression result is calculated as a real value and converted to the data cell type of the output map.

If the calculation of the expression diverges or if the data cell type is not large enough, the corresponding cell is filled with the null value.

List of mathematical and logical operators that can be employed in the logic/algebraic expression.

General Operators

Precedence Operator Description Symbol Usage Example
1 Conditional Execute the second or third term of the equation conditionally to the first if then else if not isNull(i1) and isNull(i2) then
  i3
else if isNull(i1) then
  i1 – i1 / i2
else (i1 / i2) ? (i1 – i2)
2 Boolean Or or
||
not isNull(i1) or isNull(i2)
not isNull(i1) || isNull(i2)
Boolean And and
&&
not isNull(i1) and isNull(i2)
not isNull(i1) && isNull(i2)
3 Equal =
==
i1 = 2
i1 == 2
Not Equal !=
/=
<>
i1 != 2
i1 /= 2
i1 <> 2
4 Greater Than > i1 > 2
Greater Than Or Equal >= i1 >= 2
Less Than < i1 < i2
Less Than Or Equal <= i1 <= i2
5 Add + i1 + i2
Subtract i1 – i1 / i2
6 Times * i1 * i2
Divide / i1 / i2
Mod % i1 % 100
7 Power ^ i1 ^ 3
8 Catch Error Catch an algebraic error and replace it with the result of another expression ? (i1 / i2) ? (i1 – i2)
9 Boolean Not !
not
not isNull(i1)
! isNull(i1)
Negate – ceil(i1 + i2)

General Functions

Operator Description Symbol 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
Squared Root sqrt() sqrt(i1 / i4)
Sin Sin (input in radians) sin() sin(i1 / i4)
Cos Cos (input in radians) cos() cos(i1 + i2)
Tan Tan (input in radians) tan() tan(i1 * i5 + 6)
Acos Acos (output in radians) acos() acos(i1 + i2)
Asin Asin (output in radians) asin() asin(i1 + i2)
Atan Atan (output in radians) atan() atan(i1 + i2)
Ceil ceil() ceil(i1 + i2)
Exp exp() exp(i1[i1 + i2])
Floor floor() floor(i1 + i2)
Round round() round(i1 / i4)
Abs abs() abs(i1 + i2)
Ln ln() ln(i1 / i4)
Log log() log(i1 / i4)
Max max() max(i1, i2)
Min min() min(i1, i4)
Signal Return +1, if the expression is positive, -1, if it is negative, and 0, otherwise. signal() signal(i1 - 4)
Abort Abort the model execution abort if i1 > 0 then i1 * i2 + 4 else abort

Value Operators

Operator Description Symbol 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 Symbol Usage Example
Get Image Value Return the image value at the current cell iX
where X is an integer value from 1 to 100
i2
Get Image Value At Location Return the image value on the specified cell coordinate iX[ , ]
where X is an integer value from 1 to 100
i1[line – 1, column – 2]
Get Image Null Value Return the null value of the current image null
null(iX)
if i1 > 2 then i1 else null
if null(i2) > 2 then 1 else null
Is Null isNull(iX)
where X is an integer value from 1 to 100
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

Table Operators

Table operators return the value corresponding to a given key according to a rule-operator.

It uses the following syntax:
 tX[N ]
where:
 X is a table identifier;
 N is the rule-operator.

Operator Description Symbol Usage Example
Get Table Value Return the table value in the X key position of the table tX[ ]
where X is an integer value from 1 to 100
t2[i1 + 2]
Get Table Equal Lower Bound Value Return the table value in the greater key less than or equal to the X key position of the table. tX[<= ]
tX{ }
where X is an integer value from 1 to 100
2[<= 14]
t2{14}
Get Table Lower Bound Value Return the table value in the greater key less than the X key position of the table. tX[< ]
where X is an integer value from 1 to 100
t2[< i1 + 2]
Get Table Equal Upper Bound Value Return the table value in the lesser key greater than or equal to the X key position of the table. tX[>= ]
where X is an integer value from 1 to 100
t2[>= i1 + i3]=
Get Table Upper Bound Value Return the table value in the lesser key greater than the X key position of the table. tX[> ]
where X is an integer value from 1 to 100
t2[> i7]
Get Table Closest Value Return the table value in the key closest to the X key position of the table. tX[>< ]
where X is an integer value from 1 to 100
t2[>< 3 + i7]
Get Table Interpoled Value Return a linear interpoled value drawn through the neighbor keys of the X key position of the table. tX[/ ]
where X is an integer value from 1 to 100
t2[/ i2]
Test Table Key Return 1, if expression corresponds to a key stored in the table, and 0, otherwise. tX[? ]
tX[=? ]
tX[==? ]
where X is an integer value from 1 to 100
t2[? i2]
t2[=? i2]

Image Neighborhood Functions

Neighborhood operators return the value of an operation within a defined neighborhood window. It uses the following syntax:
 nbN(iX, h, w, y, x)
where:
 N is the operator name;
 X 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(iX, h, w)

Operator Description Symbol 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) + nbStdDev(i2, 3, 3) + nbStdDev(i2, 3, 3, line+1, column)

Internal Name

CalculateMap