Using map algebra in GRASS
Using Map Algebra and the command line in GRASS
Contents
Introduction
GRASS is a geographic information system (GIS) software that is used for geospatial data management and analysis. If you find yourself working on raster data specifically in GRASS it may be very useful to know how to use map algebra in order to manipulate the data so that you can properly analyze it. also it is important to know how to use this tool using the command line instead of the graphical user interface (GUI) and so to that end for this whole page all of the examples will be done using the command line commands.
Map algebra
What is Map Algebra?
map algebra is a way in GRASS to perform arithmetic on raster layers in maps. the way that it works is that it will take two raster layers and it performs an operation on them based on what you tell it to do. for example if you wanted to cut a raster image down to the study area of another you could do that by using the fallowing command:
r.mapcalc --overwrite rasterAnew=”if(rasterB, rasterA)”
this command basically tells the program that for the new raster that you are creating if raster B(the study area) is in that location then put raster A(the raster you are cutting) there, meaning that the end result should be whatever you are measuring in raster A in just the area of raster B.
What can you do with Map Algebra?
Command line
Examples
Conclusion
References
“Mapcalc Manual.” GRASS GIS Manual: R.mapcalc, GRASS Development Team, grass.osgeo.org/grass76/manuals/r.mapcalc.html.