Masthead

Raster Math

One of the most powerful things we can do with rasters is run mathematical operations on them. Some examples might include:

These and other raster calculations are performed regularly by GIS professionals.

The concept of Raster math was introduced by Dana Tomlin and Joseph Berry in the 1970's. The idea what that you could perform math on a raster on a pixel by pixel basis.

Some real-life examples where raster math was used include:

The sections below will illustrate the different types of operations we can perform on raster data: scalar with a raster, raster with a raster, functions on a raster, and boolean raster operations.

Functions on Rasters

There are a variety of functions we can apply to the pixels in a raster. Below is a tool that allows you to try a few of the functions and see the result on the pixel values and the pixels themselves.

Note: the output values are limited to 0 to 255 so they correspond directly to intensity values displayed by your monitor.

Dimensions of the raster:

 

103
27
76
79
66
254
225
234
35
=
5.40e+44
5.32e+11
1.01e+33
2.04e+34
4.61e+28
2.05e+110
5.20e+97
4.22e+101
1.59e+15
   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Math with a Raster and a Scalar value

For "Scalar with a Raster" we are taking a "scalar" value (e.g. a single numeric value) and using it to "operate" on a raster. An example would be adding "2" to all the values in a raster or dividing all the values in a raster by 2. Try this an other operations in the tool below.

Dimensions of the raster:

 

167
210
152
247
236
65
73
115
72
=
167
210
152
247
236
65
73
115
72
   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Raster with another Raster Math

For "Raster with another Raster" we are operating on one raster with another raster. This would include adding two rasters together or dividing the values in one raster by the values in another. Remember that these are pixel by pixel operations. Try the tool below.

Dimensions of the raster:

 

198
119
222
208
232
31
237
190
56
70
171
181
15
107
230
178
160
84
=
268
290
403
223
339
261
415
350
140
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

 

 

Comparisons Between Rasters

We can execute "comparisons" between two rasters and the result will be a "boolean" raster. The comparisons include; equals ("="), not equals ("!="), less than ("<"), greater than (">"), less than or equals ("<="), and greater than or equals (">="). The result of a comparison is a "Boolean" value which can only be "true" or "false". "true" is set inside the computer as a one while "false" is a zero. You can refer to boolean values as true or false or as 1 or 0. Either is correct and common.

Dimensions of the raster:

 

0
16
46
121
231
123
77
184
153
168
78
49
236
33
44
101
200
205
=
false
false
false
false
false
false
false
false
false
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

Boolean Operations on Rasters

Once we have a couple of boolean rasters, we can perform operations on the rasters to find where one raster contains "true" values (or 1) AND the other contains "true" values. An example would be finding where there is habitat for wolves AND habitat for deer. We can also find where one raster contains "true" values OR the other contains "true" values. Here the words "AND" and "OR" take on special meanings.

Dimensions of the raster:

 

1
0
1
1
1
1
1
0
1
1
1
0
1
1
0
0
0
0
=
1
0
0
1
1
0
0
0
0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Con!

The conditional function is very important in ArcGIS because it allows us to convert a particular set of pixels to another value. There are many instances when you can't use the Reclassify tool for this because it will convert your raster pixels to integer values, potentially losing a great deal of accuracy and precision. The "Con()" function in Raster Calculator takes three parameters:

Con(ConditionalRaster,TrueRasterOrScalar,FalseRasterOrScalar)

The ConditionalRaster can be an existing boolean raster with just 1s and 0s or a comparison that creates a boolean raster. The "TrueRasterOrConstant" is the value that will replace the pixels where the ConditionalRaster is TRUE. The "TrueRasterOrScalar" can be an existing raster or a scalar value. The "FalseRasterOrScalar" value will replace the pixels where the COnditionalRaster is FALSE. The "FalseRasterOrScalar" can be and existing raster or a scalar value.

Some examples include:

Raster Calculator in ArcGIS

The video below will show you how to perform some raster mathematics in ArcGIS's "Raster Calculator".

Test Your Knowledge

What is the common name for the cells in a raster?

Grids
Cells
Square Things
Pixels

Next ->

© Copyright 2018 HSU - All rights reserved.