Using the Raster Calculator for Map Algebra
This tutorial demonstrates four map algebra calculations using the Raster Calculator tool in QGIS.
Included in this tutorial:
Accessing the Raster Calculator Tool
Raster Calculator Inputs and Parameters
Using the Raster Calculator: Four Examples
Software version in examples: QGIS-LTR 3.44.10-Solothurn
Tutorial Data: The tutorial includes demonstration with sample data available here.
Credits: Sally Kaye and L. Meisterlin (2026)
Reminder: In order to perform map algebra reliably, the cells of the different raster layers must align, though they do not need to be coterminous (i.e., they do not need to have the same extents).
Note on the layers used for demonstration in this tutorial: The example input rasters in all four examples were produced by converting the Tracts_Points1_join feature class to raster layers using the values in the “count_”, “sum_dec_a”, and “sum_dec_b” fields then reclassifying, for the purposes of demonstration.
Accessing the Raster Calculator Tool
You can access the Raster Calculator tool by clicking the Processing Toolbox icon and navigating to Raster Analysis > Raster Calculator. You can also find the tool under Raster in the menu bar.
two options for accessing the Raster Calculator
Raster Calculator Inputs and Parameters
The Raster Calculator tool allows you to create expressions that relate values of raster layers using operations. The tool’s parameters are:
Input layers: Click the three dots icon to select as many raster layers from the project as you would like to include in your expression, using the checkboxes.
Expression: This is the algebraic calculation that uses raster cell values. You can type directly in this box using layer names and operations, or click the expression icon to select layers and operations by (double-)clicking.
Output extent (optional):
Output cell size (optional):
Calculated: Choose how to save the calculated raster. By default, QGIS will open it as a temporary layer, or click the three dots to choose a location and name for the file.
parameters in the Raster Calculator dialogue box
Using the Raster Calculator: Four Examples
Example 1: Adding Two Raster Layers
The following is an example of adding two layers: Reclass_sum_dec_a (symbolized in green) and Reclass_sum_dec_b (symbolized in blue). They each have values ranging from 1 to 5.
Reclass_sum_dec_a raster with values 1 to 5
Reclass_sum_dec_b raster with values 1 to 5
Now, in the Raster Calculator expression dialogue box, we will build out the expression by selecting our layers, double-clicking raster layers, and clicking our operation to populate the expression text box. In this example, after selecting our layers, we:
Double-click Reclass_sum_dec_a from the Layers list
Click + from the Operations grid
Double-click Reclass_sum_dec_b from the Layers list
Click OK to return to the main dialogue box
Click Run to run the calculation
We choose to keep the default temporary layer output, called Calculated. The output Calculated raster is shown with a black-and-white color ramp. Notice that the maximum output value is 10 (5+5).
filling out the raster calculator expression to add Reclass_sum_dec_a and Reclass_sum_dec_b
NOTE: The @ symbol in the expression indicates the specific band of the input raster datasets. In this case, each is a single-band raster. Thus, both indicate the first (and only) band in the dataset by adding “@1” after the layers’ names.
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_sum_dec_a layer by 2.
Now, in the Raster Calculator expression dialogue box, we will build out the map algebra expression, again by clicking elements 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_sum_dec_a@1” * 2) + “Reclass_dec_sum_b@1”.
the raster calculator with the expression described above including addition and multiplication
After clicking OK and Run to run the tool, the output raster (symbolized with a black-and-white color ramp) contains values between 4 and 15.
the resulting raster layer from Example 2
Example 3: Subtraction Between Layers
The following is an example of subtracting the values in the Reclass_sum_dec_a layer from the Reclass_sum_dec_b 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 clicking from the list of rasters we have chosen and the operations grid.
In our example, the resulting expression is "Reclass_sum_dec_b" - "Reclass_sum_dec_a".
the raster calculator with the expression described above subtracting one raster from the other
After clicking OK and Run to run the tool, the output raster (symbolized with a black-and-white color ramp) contains values between -4 and 3. The minimum value is -4, as expected (1-5). While the maximum possible value is technically 4 (5-1), we can see that none of the cells in the Reclass_sum_dec_a layer with a value of 1 overlapped with a cell in the Reclass_sum_dec_b with a value of 5.
the resulting raster layer from the expression above
Example 4: Multiplying by a Binary Raster
The following is an example of multiplying the Reclass_sum_dec_a raster (again symbolized in green) and a binary layer Reclass_sum_dec_b (symbolized in orange and purple).
Reclass_sum_dec_a raster with values 1 to 5
Reclass_count raster with values 0 and 1
Anticipating Results: Because the Reclass_count 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 expression dialogue box, we will build out the map algebra expression by clicking from the layers we have previously selected and the * (multiplication) operation from the operations grid.
In our example, the resulting expression should read “Reclass_sum_dec_a” * “Reclass_count.”
the raster calculator with the expression described above multiplying the two rasters
After clicking OK and Run to run the tool, the output raster (symbolized below with a white-to-black color ramp) includes values between 0 and 5, which confirms our anticipated minimum and maximum values.
the resulting raster layer from the expression above