Geography Reference
In-Depth Information
Map or “grid” algebra allows you to perform operations on raster maps
in GRASS. This can be useful for a number of things, depending on your
data. You might recall that we have already used some map algebra
( r.mapcalc ) in Chapter 10 , Geoprocessing, on page 149 when processing
rasters.
The QGIS-GRASS toolbox includes a graphic means to design a set of
operations to create a new raster from a set of input maps. Essentially
you are creating a model that can be run to perform the operation(s).
To illustrate, we'll convert our DEM from meters to feet, a simple matter
of multiplication.
To convert the DEM, the value of each cell in meters must be multiplied
by 3.28 to convert it to feet. Given that our simple little DEM contains
225,500 cells, this is no trivial matter. Fortunately, the r.mapcalc mod-
ule makes this easy to do.
First we'll look at a complete “model” and then explain the process of
putting it together. In Figure 12.16 , on the next page, you can see the
completed model ready to run.
So, how did we build the model? Basically, it's a select-drag-drop oper-
ation for each component. The tools on the toolbar allow you to add a
map, constant, function, and connector. We started out by adding the
DEM, which must already be loaded into QGIS; otherwise, it won't show
up in the list of available maps. We then added the constant 3.28 and a
multiply operator. The output “widget” was already on the model when
we started. Once all the parts are in place, we just use the Add connec-
tion tool to connect them, making sure they are in the proper sequence.
The last step is to enter a name for the output map, and then we are
ready to run it.
When we run the model, it's really just building up a GRASS r.mapcalc
command for us in the background and executing it. It multiplies each
cell in the Ancc6_dem by 3.28 and stores the value in the output map.
When complete, we have a new raster map that looks just like the orig-
inal when displayed in QGIS, but the units are in feet rather than
meters. If you think you may want to run the model again, you can
save it for future use by clicking the Save tool in the toolbar. When it
comes time to run the model again, start the r.mapcalc module, and
load the model using the Open tool on the toolbar.
This simple example illustrates how to use the r.mapcalc module to
build a model and run it. We didn't look at all the functions, but there
 
Search WWH ::




Custom Search