-
Notifications
You must be signed in to change notification settings - Fork 64
Map Algebra Overview
Map algebra is a language used within MrGeo to perform algebraic operations on inputs (e.g. images ingested into MrGeo) to produce an output. The operations will be performed for each pixel of the inputs, utilizing the Hadoop cluster to distribute the computations.
It includes raster math operations like addition, subtraction, division, multiplication, trigonometric functions as well as more complex operations like slope and cost distance. A map algebra script can be as simple as executing a single function on a single input, or it can make use of multiple inputs or chain a series of operations together to execute more complicated computations.
Map algebra can be executed on the command line or through a request to a web service once the MrGeo WAR is deployed to a web server.
For developers needing additional capability, new map algebra functions can be written using Java and included via a plugin mechanism.
Please refer to the map algebra reference for information on available map algebra functions.
When using a MrsPyramid image as an input, the image name should be surrounded in square brackets as in:
[myimage] + 1
which produces an image in which each pixels is one larger than the corresponding pixel from the "myimage" input image.
You can use variable assignment to retain intermediate results and subsequently pass those results into subsequent operations. For example:
s1 = [myimage] + 1
d1 = s1 / 2
The last operation in a map algebra script is the result that is persisted to the specified output image name. The results of other operations used as inputs to that final operation are not kept (unless the "save" map algebra function is explicitly used). For example, in the above example in the "Variables" section, the result assigned to the variable "d1" is saved as the final result to the user-specified output image name, but the result assigned to "s1" is not kept.
Internally, a map algebra script is broken down into an execution tree with the final operation in the script serving as the root of that tree. Inputs to that operation become children of the root, and inputs to those operations become grandchildren of the root, and so on.
The operations are executed beginning with the lowest operations in the execution tree since they must be resolved in order to be used as inputs to the operations higher up in the execution tree.