Using the Raster Calculator for Map Algebra
Included in this tutorial:
Accessing the Raster Calculator tool
Raster Calculator options and parameters
Four Examples of simple operations between layers with the raster calculator
Software version in examples: ArcGIS Pro 3.0.0
Tutorial Data: The tutorial includes demonstration with sample data available here.
Credits: L. Meisterlin and Varisa Tanti (2022)
This tutorial demonstrates four map algebra calculations using the Raster Calculator tool in ArcGIS Pro.
The example input rasters in all four examples were produced by converting the Tract feature class in the Tutorial Data Standard Data Package to raster layers and reclassifying values using the values in the “count_,” “sum_dec_a,” and “sum_dec_b” fields, for the purposes of demonstration.
Reminder: In order to perform map algebra, the cells of the different raster layers must align, though they do not need to be coterminous (as in, they do not need to have the same extents).
Related: This tool requires either the Spatial Analyst Extension or the 3D Analyst Extension in ArcGIS Pro. To verify your extensions, see Which Esri Extensions Is My Software Licensed to Use?
Accessing the Raster Calculator Tool
You can access the Raster Calculator tool by clicking the Geoprocessing toolbox in the main ribbon, and clicking through Spatial Analysis Tools > Map Algebra > Raster Calculator in the Geoprocessing Pane. You can also search for “Raster Calculator” in the Geoprocessing Pane’s search bar.
Raster Calculator Options & Parameters
In the Raster Calculator dialogue box, you will see the Map Algebra expression calculator, which has two columns (one for Rasters and one for Tools), an expression text box, and output raster.
You will select from the Rasters and Tools column to build out your equation in the equation table.
Here’s a brief description of the different inputs:
Map Algebra expression: In this calculator, you will build out the map algebra expression that you want to run. This expression is composed of specifying the inputs (Raster column) and the operators (Tools column)
Rasters: This column displays the raster layers in your map project that can be used in your equation. Note: You can also browse for raster layers that are not included in your map project by clicking on the yellow folder icon at the top of the Rasters list.
Tools: This column displays the operations available to run in your equation.
Expression text box: This text box displays the expression to be evaluated by the calculator. (Hint: you can also type in the text box.)
Output raster: The location and name of the output raster
Using the Raster Calculator: Four Examples
Example 1: Adding Two Raster Layers
The following is an example of adding two layers: Reclass_Count (symbolized in blue) and Reclass_sum_dec_a (symbolized in green). They each have values ranging from 1 to 5.
Now, in the Raster Calculator dialogue box, we will build out the expression by double-clicking on the elements in both the Rasters and Tools lists to populate the Map Algebra expression text box.
Double-click Reclass_Count from the Rasters list.
Double-click + from the Tools list.
And double-click Reclass_sum_dec_a from the Rasters list.
Indicate the name and output location of your output raster.
Click Run to execute the tool.
The output raster of our example is shown on the right, symbolized on a black-and-white color ramp. Notice that the output values are between 2 and 10. This is because the minimum additive possibility is 1+1 and the maximum additive possibility is 5+5.
Example 2: Addition and Multiplication
The following is an example of adding the same two layers as above (in Example 1), while also multiplying the Reclass_Count by 2.
Now, in the Raster Calculator dialogue box, we will build out the map algebra expression, again by double-clicking from the two lists (as before) and also typing in the text field. For the sake of demonstration (and tidiness), we are including parentheses in our expression. (These parentheses aren’t necessary in this case, but they can help for clarity. Remember to mind the arithmetic order of operations for evaluating expressions!)
In our example, the resulting expression is ("Reclass_Count" * 2) + "Reclass_sum_dec_a".
After running the tool (by clicking Run), the output raster output raster (shown at right, symbolized with a black-and-white color ramp) contains values between 3 and 15. This is because the minimum possibility is (12)+1 and the maximum is (52)+5.
Example 3: Subtraction between Layers
The following is an example of subtracting the values in the Reclass_sum_dec_a layer from the Reclass_Count layer. Again, these are the same layers used in the previous examples. (When the two layers represent different moments, subtraction can calculate change over time.)
Now, in the Raster Calculator dialogue box, we will build out the map algebra expression, by double-clicking from the list of rasters and the list of tools.
In our example, the resulting expression is "Reclass_Count" - "Reclass_sum_dec_a".
After running the tool (by clicking Run), the output raster will represent the difference between the values in these two layers. In our example (shown on the right), most cells in the output raster indicate no difference (cell value 0, symbolized in yellow), many cells show areas were the Reclass_sum_dec_a has a slightly higher value (cell value -1, symbolized in red), and some cells indicate areas where the Reclass_Count layer has slightly higher values (cell value 1, symbolized in green).
Example 4: Multiplying by a Binary Raster
The following is an example of multiplying the Reclass_Count (again symbolized in blue) and a binary layer Reclass_sum_dec_b (symbolized in orange and magenta).
Anticipating Results: Because the Reclass_sum_dec_b raster has binary values, we anticipate the results to include cells with zero values (where Reclass_Count overlaps with 0-value cells in Reclass_sum_dec_b), because the product of any value and zero is zero. (And, of course, the product of any value and one is the original value.)
Now, in the Raster Calculator dialogue box, we will build out the map algebra expression by double-clicking from the options listed in the dialogue box.
In our example, the resulting expression should read "Reclass_Count" * "Reclass_sum_dec_b".
After running the tool (by clicking Run), the output raster (symbolized at right with a black-and-white color ramp) includes values between 0 and 4, which confirms our anticipated minimum value (0). While the maximum possible product is technically 5, we can see from the output that none of the cells in the Reclass_Count field with values of 5 overlapped with cells equal to 1 in the example binary layer.