Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4, available here.
Updated manual page: here
The user can specify all needed parameters on the command line, and run the program non-interactively. If the user does not specify any categories (e.g., using the optional cats=range[,range,...] argument), then all the category values and labels for the named raster map layer that occur in the map are printed. The entire map is read using r.describe, to determine which categories occur in the map. If a listing of categories is specified, then the labels for those categories only are printed. The cats may be specified as single category values, or as ranges of values. The user may also (optionally) specify that a field separator other than a space or tab be used to separate the category value from its corresponding category label in the output, by using the separator=character|space|tab option (see example below). If no field separator is specified by the user, a tab is used to separate these fields in the output, by default.
The output is sent to standard output in the form of one category per line, with the category value first on the line, then an ASCII TAB character (or whatever single character or space is specified using the separator parameter), then the label for the category.
The output from r.category can be redirected into a file, or piped into another program.
cat:Label val1:val2:Label
0:no data 2: . 5: . ## explicit category labels 7: .
5.5:5:9 label description or 15:30 label description
In the format line
Also, the form $?xxx$yyy$ translates into yyy if the category is 1, xxx otherwise. The $yyy$ is optional. Thus
$1 meter$?s
will become:
1 meter (for category 1)
2 meters (for category 2), etc.
format='Elevation: $1.2 to $2.2 feet' ## Format Statement
coefficients="5.0,1000,5.0,1005" ## Coefficients
The format and coefficients above would be used to generate the following statement in creation of the format appropriate category string for category "num":
sprintf(buff,"Elevation: %.2f to %.2f feet", num*5.0+1000, num*5.0*1005)
Note: while both the format and coefficient lines must be present a blank line for the format string will effectively suppress automatic label generation.
To use a "$" in the label without triggering the plural test, put "$$" in the format string.
Use 'single quotes' when using a "$" on the command line to avoid unwanted shell substitution.
r.category map=soils
r.category map=soils cats=10,12,15-20
r.category map=soils cats=10,20 separator=':'
10:Dumps, mine, Cc 20:Kyle clay, KaA
r.category diseasemap separator=: rules=- << EOF 1:potential absence 2:potential presence EOF
d.what.rast, r.coin, r.describe, r.support
Last changed: $Date: 2016-11-30 07:49:35 -0800 (Wed, 30 Nov 2016) $
Available at: r.category source code (history)
Note: A new GRASS GIS stable version has been released: GRASS GIS 7.4, available here.
Updated manual page: here
Main index | Raster index | Topics index | Keywords index | Full index
© 2003-2018 GRASS Development Team, GRASS GIS 7.0.7svn Reference Manual