1r.category(1) Grass User's Manual r.category(1)
2
3
4
6 r.category - Manages category values and labels associated with user-
7 specified raster map layers.
8
10 raster
11
13 r.category
14 r.category help
15 r.category map=name [cats=range[,range,...]]
16 [vals=float[,float,...]] [fs=character|space|tab] [raster=name]
17 [rules=name] [format=string] [coefficients=mult1,offset1,mult2,off‐
18 set2] [--verbose] [--quiet]
19
20 Parameters:
21 map=name
22 Name of input raster map
23
24 cats=range[,range,...]
25 Category values
26 Example: 1,3,7-9,13
27
28 vals=float[,float,...]
29 Comma separated value list
30 Example: 1.4,3.8,13
31
32 fs=character|space|tab
33 Output field separator
34 Default: tab
35
36 raster=name
37 Raster map from which to copy category table
38
39 rules=name
40 File containing category label rules (or "-" to read from stdin)
41
42 format=string
43 Default label or format string for dynamic labeling
44 Used when no explicit label exists for the category
45
46 coefficients=mult1,offset1,mult2,offset2
47 Dynamic label coefficients
48 Two pairs of category multiplier and offsets, for $1 and $2
49
51 r.category prints the category values and labels for the raster map
52 layer specified by map=name to standard output.
53
54 The user can specify all needed parameters on the command line, and run
55 the program non-interactively. If the user does not specify any cate‐
56 gories (e.g., using the optional cats=range[,range,...] argument),
57 then all the category values and labels for the named raster map layer
58 that occur in the map are printed. The entire map is read using
59 r.describe, to determine which categories occur in the map. If a list‐
60 ing of categories is specified, then the labels for those categories
61 only are printed. The cats may be specified as single category values,
62 or as ranges of values. The user may also (optionally) specify that a
63 field separator other than a space or tab be used to separate the cate‐
64 gory value from its corresponding category label in the output, by
65 using the fs=character|space|tab option (see example below). If no
66 field separator is specified by the user, a tab is used to separate
67 these fields in the output, by default.
68
69 The output is sent to standard output in the form of one category per
70 line, with the category value first on the line, then an ASCII TAB
71 character (or whatever single character or space is specified using the
72 fs parameter), then the label for the category.
73
75 Any ASCII TAB characters which may be in the label are replaced by spa‐
76 ces.
77
78 The output from r.category can be redirected into a file, or piped into
79 another program.
80
81 Input from a file
82 The rules option allows the user to assign category labels from values
83 found in a file. The label can refer to a single category, range of
84 categories, floating point value, or a range of floating point values.
85 The format is given as follows.
86 cat:Label
87 val1:val2:Label
88 If the filename is given as "-", the category labels are read from
89 stdin
90
91 Default and dynamic category labels
92 Default and dynamic category labels can be created for categories that
93 are not explicitly labeled. The coefficient line can be followed by
94 explicit category labels which override the format label generation.
95 0:no data
96 2: .
97 5: . ## explicit category labels
98 7: .
99 explicit labels can be also of the form:
100 5.5:5:9 label description
101 or
102 15:30 label description
103
104
105 In the format line
106
107 $1 refers to the value num*5.0+1000 (ie, using the first
108 2 coefficients)
109
110 $2 refers to the value num*5.0+1005 (ie, using the last 2
111 coefficients)
112 $1.2 will print $1 with 2 decimal places.
113
114 Also, the form $?xxx$yyy$ translates into yyy if the category is 1, xxx
115 otherwise. The $yyy$ is optional. Thus
116
117 $1 meter$?s
118
119 will become: 1 meter (for category 1)
120 2 meters (for category 2), etc.
121
122 format='Elevation: $1.2 to $2.2 feet' ## Format Statement coeffi‐
123 cients="5.0,1000,5.0,1005" ## Coefficients
124
125 The format and coefficients above would be used to generate the follow‐
126 ing statement in creation of the format appropriate category string for
127 category "num":
128
129 sprintf(buff,"Elevation: %.2f to %.2f feet", num*5.0+1000,
130 num*5.0*1005)
131
132 Note: while both the format and coefficent lines must be present a
133 blank line for the format string will effectively suppress automatic
134 label generation.
135
136 To use a "$" in the label without triggering the plural test, put "$$"
137 in the format string.
138
139 Use 'single quotes' when using a "$" on the command line to avoid
140 unwanted shell substitution.
141
143
144 r.category map=soils
145 prints the values and labels associated with all of the categories in
146 the soils raster map layer;
147 r.category map=soils cats=10,12,15-20
148 prints only the category values and labels for soils map layer cate‐
149 gories 10, 12, and 15 through 20; and
150 r.category map=soils cats=10,20 fs=':'
151 prints the values and labels for soils map layer categories 10 and 20,
152 but uses ":" (instead of a tab) as the character separating the cate‐
153 gory values from the category values in the output.
154
155 Example output:
156
157
158 10:Dumps, mine, Cc
159 20:Kyle clay, KaA
160
161
163 Respect the fs= field separator setting for input rules.
164
166 UNIX Manual entries for awk and sort
167
168 r.coin, r.describe, d.what.rast, r.support
169
171 Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
172 Hamish Bowman, University of Otago, New Zealand (label creation
173 options)
174
175 Last changed: $Date: 2008-01-25 19:42:36 +0100 (Fri, 25 Jan 2008) $
176
177 Full index
178
179 © 2003-2008 GRASS Development Team
180
181
182
183GRASS 6.3.0 r.category(1)