1r.reclass(1) GRASS GIS User's Manual r.reclass(1)
2
3
4
6 r.reclass - Reclassify raster map based on category values.
7 Creates a new raster map whose category values are based upon a reclas‐
8 sification of the categories in an existing raster map.
9
11 raster, reclassification
12
14 r.reclass
15 r.reclass --help
16 r.reclass input=name output=name rules=name [title=string] [--over‐
17 write] [--help] [--verbose] [--quiet] [--ui]
18
19 Flags:
20 --overwrite
21 Allow output files to overwrite existing files
22
23 --help
24 Print usage summary
25
26 --verbose
27 Verbose module output
28
29 --quiet
30 Quiet module output
31
32 --ui
33 Force launching GUI dialog
34
35 Parameters:
36 input=name [required]
37 Name of raster map to be reclassified
38
39 output=name [required]
40 Name for output raster map
41
42 rules=name [required]
43 File containing reclass rules
44 ’-’ for standard input
45
46 title=string
47 Title for output raster map
48
50 r.reclass creates an output map layer based on an input integer raster
51 map layer. The output map layer will be a reclassification of the in‐
52 put map layer based on reclass rules input to r.reclass, and can be
53 treated in much the same way that raster maps are treated. A TITLE for
54 the output map layer may be (optionally) specified by the user.
55
56 The reclass rules are read from standard input (i.e., from the key‐
57 board, redirected from a file, or piped through another program).
58
59 Before using r.reclass the user must know the following:
60
61 1 The new categories desired; and, which old categories fit into
62 which new categories.
63
64 2 The names of the new categories.
65
67 In fact, the r.reclass program does not generate any new raster map
68 layers (in the interests of disk space conservation). Instead, a re‐
69 class table is stored which will be used to reclassify the original
70 raster map layer each time the new (reclassed) map name is requested.
71 As far as the user (and programmer) is concerned, that raster map has
72 been created.
73
74 r.reclass only works on an integer input raster map; if the input map
75 is instead floating point data, you must multiply the input data by
76 some factor to achieve whole number input data, otherwise r.reclass
77 will round the raster values down to the next integer.
78
79 Also note that although the user can generate a r.reclass map which is
80 based on another r.reclass map, the new r.reclass map will be stored in
81 GRASS as a reclass of the original raster map on which the first re‐
82 classed map was based. Therefore, while GRASS allows the user to pro‐
83 vide r.reclass map layer information which is based on an already re‐
84 classified map (for the user’s convenience), no r.reclass map layer
85 (i.e., reclass table) will ever be stored as a r.reclass of a r.re‐
86 class.
87
88 To convert a reclass map to a regular raster map layer, set your geo‐
89 graphic region settings to match the settings in the header for the re‐
90 class map (with "g.region raster=reclass_map", or viewable by running
91 r.info) and then run r.resample.
92
93 r.mapcalc can be used to convert a reclass map to a regular raster map
94 layer as well:
95 r.mapcalc "raster_map = reclass_map"
96
97 where raster_map is the name to be given to the new raster map, and re‐
98 class_map is an existing reclass map.
99
100 Because r.reclass generates internally simply a table by referencing
101 some original raster map layer rather than creating a full new re‐
102 classed raster map layer, a r.reclass map layer will no longer be ac‐
103 cessible if the original raster map layer, upon which it was based, is
104 later removed. Therefore, attempting to remove a raster map layer from
105 which a r.reclass has been derived is only possible if the original map
106 is removed first. Alternatively, a r.reclass map can be removed in‐
107 cluding its base map by using
108
109 g.remove’s -b flag.
110
111 A r.reclass map is not a true raster map layer. Rather, it is a table
112 of reclassification values which reference the input raster map layer.
113 Therefore, users who wish to retain reclassified map layers must also
114 save the original input raster map layers from which they were gener‐
115 ated. Alternatively r.recode can be used.
116
117 Category values which are not explicitly reclassified to a new value by
118 the user will be reclassified to NULL.
119
120 Reclass Rules
121 Each line of input must have the following format:
122 input_categories=output_category [label]
123
124 where each line of input specifies the category values in the input
125 raster map layer to be reclassified to the new output_category category
126 value. Specification of a label to be associated with the new output
127 map layer category is optional. If specified, it is recorded as the
128 category label for the new category value. The equal sign = is re‐
129 quired. The input_category(ies) may consist of single category values
130 or a range of such values in the format "low thru high." The word
131 "thru" must be present.
132
133 To include all (remaining) values the asterix "*" can be used. This
134 rule has to be set as last rule. No further rules are accepted after
135 setting this rule. The special rule "* = *" specifies that all cate‐
136 gories not expicitly set by one of the above rules should be passed
137 through unaltered instead of being set to NULL.
138
139 Categories to become no data are specified by setting the output cate‐
140 gory value to "NULL".
141
142 A line containing only the word end terminates the input.
143
145 Reclass rules examples
146 The following examples may help clarify the reclass rules.
147
148 The first example reclassifies categories 1, 2 and 3 in the input
149 raster map layer "roads" to category 1 with category label "good qual‐
150 ity" in the output map layer, and reclassifies input raster map layer
151 categories 4 and 5 to category 2 with the label "poor quality" in the
152 output map layer.
153 1 2 3 = 1 good quality
154 4 5 = 2 poor quality
155
156 The following example reclassifies categories 1, 3 and 5 in the input
157 raster map layer to category 1 with category label "poor quality" in
158 the output map layer, and reclassifies input raster map layer cate‐
159 gories 2, 4, and 6 to category 2 with the label "good quality" in the
160 output map layer. All other values are reclassified to NULL.
161 1 3 5 = 1 poor quality
162 2 4 6 = 2 good quality
163 * = NULL
164
165 The following example reclassifies input raster map layer categories 1
166 thru 10 to output map layer category 1, input map layer categories 11
167 thru 20 to output map layer category 2, and input map layer categories
168 21 thru 30 to output map layer category 3, all without labels. The
169 range from 30 to 40 is reclassified as NULL.
170 1 thru 10 = 1
171 11 thru 20 = 2
172 21 thru 30 = 3
173 30 thru 40 = NULL
174
175 The following example shows overlapping rules. Subsequent rules over‐
176 ride previous rules. Therefore, the below example reclassifies input
177 raster map layer categories 1 thru 19 and 51 thru 100 to category 1 in
178 the output map layer, input raster map layer categories 20 thru 24 and
179 26 thru 50 to the output map layer category 2, and input raster map
180 layer category 25 to the output category 3.
181 1 thru 100 = 1 poor quality
182 20 thru 50 = 2 medium quality
183 25 = 3 good quality
184
185 The previous example could also have been entered as:
186 1 thru 19 51 thru 100 = 1 poor quality
187 20 thru 24 26 thru 50 = 2 medium quality
188 25 = 3 good quality
189 or as:
190 1 thru 19 = 1 poor quality
191 51 thru 100 = 1
192 20 thru 24 = 2
193 26 thru 50 = 2 medium quality
194 25 = 3 good quality
195
196 The final example was given to show how the labels are handled. If a
197 new category value appears in more than one rule (as is the case with
198 new category values 1 and 2), the last label which was specified be‐
199 comes the label for that category. In this case the labels are as‐
200 signed exactly as in the two previous examples.
201
202 Usage example
203 In this example, the 21 classes of the landuse map (North Carolina sam‐
204 ple dataset) are simplified to 7 classes:
205 r.category landuse96_28m
206 0 not classified
207 1 High Intensity Developed
208 2 Low Intensity Developed
209 3 Cultivated
210 [...]
211 20 Water Bodies
212 21 Unconsolidated Sediment
213 # use this command or save rules with editor in textfile "landuserecl.txt"
214 echo "0 = NULL
215 1 2 = 1 developed
216 3 = 2 agriculture
217 4 6 = 3 herbaceous
218 7 8 9 = 4 shrubland
219 10 thru 18 = 5 forest
220 20 = 6 water
221 21 = 7 sediment" > landuserecl.txt
222 r.reclass input=landuse96_28m output=landclass96_recl \
223 rules=landuserecl.txt \
224 title="Simplified landuse classes 1996"
225 # verify result
226 r.category landuse96_recl
227 1 developed
228 2 agriculture
229 3 herbaceous
230 4 shrubland
231 5 forest
232 6 water
233 7 sediment
234
236 r.recode, r.resample, r.rescale
237
239 James Westervelt,
240 Michael Shapiro
241 U.S.Army Construction Engineering Research Laboratory
242
244 Available at: r.reclass source code (history)
245
246 Accessed: Mon Jun 20 16:46:22 2022
247
248 Main index | Raster index | Topics index | Keywords index | Graphical
249 index | Full index
250
251 © 2003-2022 GRASS Development Team, GRASS GIS 8.2.0 Reference Manual
252
253
254
255GRASS 8.2.0 r.reclass(1)