In MapInfo Pro Advanced, the Calculator is a powerful tool for performing mathematical and logical operations on each cell in one or more input rasters. You can perform mathematical calculations using operators and functions or set up selection queries. Inputs can be Multi-Resolution Raster files (.mrr files) or other supported rasters.
Within an expression, grids are referred to by whatever alias you will pass in using the alias
array. For example, if you want to create a raster elevation in feet from a raster in
meters, you need to use the conversion factor for meters to feet, - 3.28. The expression
is: InputRaster1 * 3.28
where InputRaster1 is the alias of the input
grid file SampleFile.grd.
Arithmetic Operators
Arithmetic operators allow for the addition, subtraction, multiplication, division, and exponentiation of single or multiple rasters.
For example, to determine the mean value for every cell between two rasters, you must type this expression in the Expression Editor:
(InputRaster1 + InputRaster2)/2
For more information, see Arithmetic Operators.
Comparison and Logical Operators
- These operators evaluate specific conditions. For example, if a water body is
represented by a cell value of 100 and you want to identify all other land uses
except water body regions, you must type this expression in the Expression
Editor:
InputRaster <> 100
- ANY operator. Use ANY function to match against a collection/range of values. Returns TRUE (1)
if the Raster Cell Value matches with the specified collection or
range. Each argument can either be a numeric value, or a range specified as
n1..n2 or n1:n2, where n1 and n2 are real numbers. For example,
cond(Any(Input_1, 22, 100 200..300, 500:600) , Input_1, null)
Numeric Functions
Numeric functions are applied to the values in a single input raster. There are:
- arithmetic functions like abs(x) and ceil(x). For example,
abs(InputRaster1)
. - logarithmic functions like ln(x) and log(x). For example,
log(InputRaster1)
. - trigonometric functions like sin(x) and tan(x). For example,
sin(InputRaster1)
. - power functions like pow(x,y) and sqrt(x). For example,
pow(InputRaster1,2)
.
Raster Statistics Functions
You can use the statistics operators to evaluate raster statistics like variance, mean, standard deviation of grid files. The calculator statistics functions support band index also. Raster statistics functions work on single-band. To work on other bands of a field you need to open another instance of it. For more information, refer to Raster Statistics Functions.
Logical and Conditional Functions
Conditional functions like Cond, Any, Xor, and Not enables you to evaluate conditions where one value is returned when a condition is TRUE, else another value is returned when the condition is FALSE.
- COND function. Use COND function to perform conditional tests. The syntax is
COND ((logical_condition), value_if_TRUE, value_if_FALSE)
. For example, in a grid file, if you want to find all values greater than 1000 and set all other values to NULL, you will useCOND (InputRaster1>1000, InputRaster1, NULL)
. You can also use numeric functions in a COND statement. For example,COND (max(InputRaster1,InputRaster2), InputRaster1+10000, InputRaster2+20000)
. You can also use the expressionif logical_condition then value_if_true else value_if_false endif
. - NOT function. Use NOT function to make a value not equal to another. The syntax is
NOT (logical_condition)
. For example,COND (NOT(InputRaster1<1000), InputRaster1, InputRaster1+2000)
. - XOR function. Use XOR function to return TRUE if only one condition is TRUE; else return FALSE if both conditions are FALSE or both conditions are TRUE. The syntax is
XOR (logical_condition1, logical_condition2)
. For example,COND (XOR (InputRaster1<1000, InputRaster2>1000), OutputRaster1, OutputRaster2)
. In this example, if either of the conditions is TRUE, then output is saved to OutputRaster1. If both the conditions are TRUE or FALSE, then output is saved to OutputRaster2
INPUT | OUTPUT | |||
---|---|---|---|---|
PRIMARY INPUT | Continuous | Classified | Image (RGB) | Image Palette |
Continuous | Yes | Yes | Yes | No |
Classified | Yes | Yes | No | No |
Image (RGB) | Yes | No | Yes | No |
Image Palette | Yes | No | Yes | Yes |