Envision's Map Algebra Language

Envision includes a mathematical expression language that can be used to evaluate map-based mathematical expressions. This is used in a variety of “standard” plug-ins, and can be accessed using user-defined plug-ins. This language allows for expressions that can contain:

  • Algebraic operators (e.g. add, subtract, etc.)
  • Logical operators (e.g. logical AND, logical OR, etc. )
  • A variety of mathematical functions (e.g. sin, cos, etc.)
  • Field references for accessing IDU-level field information (e.g. AREA, IDU_INDEX, POPDENS.) Note that field names are NOT case-sensitive.
  • Expression precedence grouping using parentheses.

Available operators and functions are specified below.

OperatorDescriptionExample
+ Addition 1 + 2
* Subtraction and unary minus1-2
* Multiplication 1*2
/ Division 1/2
^ Power 2^2
% Modulo 2%1
& Logical AND MYFIELD & 2
| Logical OR MYFIELD | 2
! Logical NOT ! MYFIELD
>, >= Greater or equal to MYFIELD > 3
<, <= Less than or equal to MYFIELD <= 3
!= Not equal MYFIELD != 3
== Equal MYFIELD == 3
( ) Precedence 1+(2*3)
FunctionReturn ValueExample
abs(x) Absolute Value of xabs(-12) => 12
acos(x) Inverse Cosine of x (radians)
asin(x) Inverse Sine of x (radians)
atan(x) Inverse Tan of x (radians)
avg(x,y,z...) Average value of the argumentsavg(1,3) => 2
ceil(x) Value of x rounded up to nearest integerceil(2.3) => 3
cos(x) Cosine of x (radians)
cosh(x) Hyperbolic cosign of x (radians)
floor(x) Value of x rounded down to nearest integerfloor(2.3) => 3
if(cond,trueEx, falseEx)Conditional expression - if 'cond' is true, return value of 'trueEx', otherwise, return the value of 'falseEx'
log(x) Natural Log of x
log10(x) Log base 10 of x
max(x,y,z,…) Maximum value of the argument list
min(x,y,z,…) Minimum value of the argument list
rand(x) Uniform Random value between (0,1)
rand(min, max) Uniform Random value between (min,max)
round(x) Value of x rounded to the nearest integer
sin(x) Sine of x (radians)
sinh(x) Hyperbolic Sine of x (radians)
sqrt(x) Square Root of x
sum(x,y,z,…) Sum of the argument list
tan(x) Tangent of x (radians)
tanh(x) Hyperbolic Tangent of x (radians)

Expression can be nested to an unlimited depth. Examples of valid expressions include:

  • 1 + sin( 0.5 )
  • 17 * AREA + log( POPDENS ) - Note: this assume AREA and POPDENS are fields in the IDU database
  • if ( area > 100, AREA * 1000, 0 ) - Note: syntax is if ( condition, expr when true, expr when false)

For more details on the expression evaluator used in Envision, see http://www.codeproject.com/Articles/7335/An-extensible-math-expression-parser-with-plug-ins