.TH r.category 1grass "" "GRASS 6.4.4" "Grass User's Manual" .SH NAME \fI\fBr.category\fR\fR - Manages category values and labels associated with user-specified raster map layers. .SH KEYWORDS raster, category .SH SYNOPSIS \fBr.category\fR .br \fBr.category help\fR .br \fBr.category map\fR=\fIname\fR [\fBcats\fR=\fIrange\fR[,\fIrange\fR,...]] [\fBvals\fR=\fIfloat\fR[,\fIfloat\fR,...]] [\fBfs\fR=\fIcharacter|space|tab\fR] [\fBraster\fR=\fIname\fR] [\fBrules\fR=\fIname\fR] [\fBformat\fR=\fIstring\fR] [\fBcoefficients\fR=\fImult1,offset1,mult2,offset2\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] .SS Parameters: .IP "\fBmap\fR=\fIname\fR" 4m .br Name of input raster map .IP "\fBcats\fR=\fIrange[,\fIrange\fR,...]\fR" 4m .br Category values .br Example: 1,3,7-9,13 .IP "\fBvals\fR=\fIfloat[,\fIfloat\fR,...]\fR" 4m .br Comma separated value list .br Example: 1.4,3.8,13 .IP "\fBfs\fR=\fIcharacter|space|tab\fR" 4m .br Field separator .br Output field separator .br Default: \fItab\fR .IP "\fBraster\fR=\fIname\fR" 4m .br Raster map from which to copy category table .IP "\fBrules\fR=\fIname\fR" 4m .br File containing category label rules (or "-" to read from stdin) .IP "\fBformat\fR=\fIstring\fR" 4m .br Default label or format string for dynamic labeling .br Used when no explicit label exists for the category .IP "\fBcoefficients\fR=\fImult1,offset1,mult2,offset2\fR" 4m .br Dynamic label coefficients .br Two pairs of category multiplier and offsets, for $1 and $2 .PP .SH DESCRIPTION \fIr.category\fR prints the category values and labels for the raster map layer specified by \fBmap=\fR\fIname\fR to standard output. You can also use it to set category labels for a raster map. .PP 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 \fBcats=\fR\fIrange\fR[,\fIrange\fR,...] argument), then all the category values and labels for the named raster map layer that occur in the map are printed. The entire \fImap\fR is read using \fIr.describe\fR, to determine which categories occur in the \fImap\fR. If a listing of categories is specified, then the labels for those categories only are printed. The \fIcats\fR 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 \fBfs=\fR\fIcharacter\fR|\fIspace\fR|\fItab\fR 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. .PP 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 \fBfs\fR parameter), then the label for the category. .SH NOTES Any ASCII TAB characters which may be in the label are replaced by spaces. .PP The output from \fIr.category\fR can be redirected into a file, or piped into another program. .SS Input from a file The \fBrules\fR option allows the user to assign category labels from values found in a file. The label can refer to a single category, range of categories, floating point value, or a range of floating point values. The format is given as follows. \fC .DS .br cat:Label .br val1:val2:Label .br .DE \fR If the filename is given as "-", the category labels are read from stdin .SS Default and dynamic category labels Default and dynamic category labels can be created for categories that are not explicitly labeled. The coefficient line can be followed by explicit category labels which override the format label generation. \fC .DS .br 0:no data .br 2: . .br 5: . ## explicit category labels .br 7: . .br .DE \fR explicit labels can be also of the form: \fC .DS .br 5.5:5:9 label description .br or .br 15:30 label description .br .DE \fR .PP In the format line .RS .IP $1 refers to the value num*5.0+1000 (ie, using the first 2 coefficients) .IP $2 refers to the value num*5.0+1005 (ie, using the last 2 coefficients) .RE $1.2 will print $1 with 2 decimal places. .PP Also, the form $?xxx$yyy$ translates into yyy if the category is 1, xxx otherwise. The $yyy$ is optional. Thus .PP $1 meter$?s .PP will become: 1 meter (for category 1) .br 2 meters (for category 2), etc. .PP format='Elevation: $1.2 to $2.2 feet' ## Format Statement coefficients="5.0,1000,5.0,1005" ## Coefficients .PP The format and coefficients above would be used to generate the following statement in creation of the format appropriate category string for category "num": .PP sprintf(buff,"Elevation: %.2f to %.2f feet", num*5.0+1000, num*5.0*1005) .PP Note: while both the format and coefficent lines must be present a blank line for the format string will effectively suppress automatic label generation. .PP To use a "$" in the label without triggering the plural test, put "$$" in the format string. .PP Use 'single quotes' when using a "$" on the command line to avoid unwanted shell substitution. .SH EXAMPLES .PP \fC .DS .br r.category map=soils .br .DE \fR prints the values and labels associated with all of the categories in the \fIsoils\fR raster map layer; \fC .DS .br r.category map=soils cats=10,12,15-20 .br .DE \fR prints only the category values and labels for \fIsoils\fR map layer categories 10, 12, and 15 through 20; and \fC .DS .br r.category map=soils cats=10,20 fs=':' .br .DE \fR prints the values and labels for \fIsoils\fR map layer categories 10 and 20, but uses ":" (instead of a tab) as the character separating the category values from the category values in the output. .PP .IP "Example output: .PP \fC .DS .br 10:Dumps, mine, Cc .br 20:Kyle clay, KaA .br .DE \fR .PP .IP "Example defining category labels: \fC .DS .br r.category diseasemap rules=- << EOF .br 1:potential absence .br 2:potential presence .br EOF .br .DE \fR sets the categoy values 1 and 2 to respective text labels. .PP .SH TODO Respect the \fBfs=\fR field separator setting for input rules. .SH SEE ALSO UNIX Manual entries for \fIawk\fR and \fIsort\fR .PP \fIr.coin\fR, \fIr.describe\fR, \fId.what.rast\fR, \fIr.support\fR .SH AUTHORS Michael Shapiro, U.S. Army Construction Engineering Research Laboratory .br Hamish Bowman, University of Otago, New Zealand (label creation options) .PP \fILast changed: $Date: 2009-02-27 04:00:29 +0100 (Fri, 27 Feb 2009) $\fR .PP Full index .PP © 2003-2014 GRASS Development Team