Grass Tutorial | ||
---|---|---|
<<< Previous | Next >>> |
In the raster data model, cell category numbers can be one of two things: either they are measurements of real-life surface values (light intensity in images, height in digital terrain models, slope, temperature, etc) or they represent classes of categories (scanned maps, land use, soil types, etc). In the first case, labels are not very necessary since the type of map defines the type of values themselves, in the second, they are indispensable in order to document the meaning of the category numbers.
In GRASS, the raster map is stored in a binary file which contains the category numbers for each cell. The category labels are stored in a text file which contains the category numbers with their respective labels. This chapter will look at different aspects of the management of categories.
The first thing you might wish to do is see which category values are present in your raster file. Here is a list of modules you can use for this purpose:
r.cats : Prints category values and labels associated with user-specified raster map layers
r.describe : Prints terse list of category values found in a raster map layer
r.what : Queries raster map layers on their category values and category labels
d.what.rast : Allows the user to interactively (with the mouse) query the category contents of multiple raster map layers at user-specified locations within the current geographic region
r.report : Reports statistics for raster map layers, by category
r.stats : Generates area statistics for raster map layers (similar to r.report
r.statistics : Category or object oriented statistics
r.univar : Univariate statistics for a GRASS raster map
For more information on statistics and reports, see the chapter called Statistics and Reports.
You have to distinguish between changing the category values of a map and changing the category labels. Actually the first is not really possible without creating a new map, dropping the old one and renaming the new one to the old one's name. You can do the latter directly on a map.
In order to create a new map by changing the category values of an already existing one, you can use the following modules:
r.reclass : Creates a new (pseudo-)map layer whose category values are based upon the user's reclassification of categories in an existing raster map layer
r.recode : Creates an output map layer based on an input raster map layer
r.rescale : Rescales the range of category values in a raster map layer (also see r.rescale.eq and r.rescale.inf
r.mapcalc : Raster map layer data calculator (see the chapter called Raster map algrebra with r.mapcalc for more detailed information)
r.clump : Recategorizes data in a raster map layer by grouping cells that form physically discrete areas into unique categories
For changing the category labels of a raster map, use r.support. Enter 'y' when you get to the question "Edit the category file for [mapname]?". You will get to a screen showing the highest category number. You normally don't want to change that, so just go on by typing ESC-RETURN to enter the category table 'editor'. To go on to the next screen of the editor, type ESC-RETURN again. To finish, just type 'end' at the "Next category" prompt.
You might wish to automate the assigning of labels. Here's an example of how you could use r.stats and r.reclass to assign the total area size in square meters of each category to each cell of that respective category: r.stats -qan in=map | awk '{printf "%d=%d %d sq meters\n", $1, $1, $2}' | r.reclass in=map out=newmap[1]
[1] | This example was taken from M. Neteler, H. Mitasova, 2002. Open Source GIS: A GRASS GIS Approach, p. 84. |
<<< Previous | Home | Next >>> |
Manage Attributes and Classes | Up | Vector Categories and Attributes |