1r.reclass(1) Grass User's Manual r.reclass(1)
2
3
4
6 r.reclass - Creates a new map layer whose category values are based
7 upon a reclassification of the categories in an existing raster map
8 layer.
9
11 raster
12
14 r.reclass
15 r.reclass help
16 r.reclass input=name output=name [rules=name] [title=string]
17 [--overwrite] [--verbose] [--quiet]
18
19 Flags:
20 --overwrite
21 Allow output files to overwrite existing files
22
23 --verbose
24 Verbose module output
25
26 --quiet
27 Quiet module output
28
29 Parameters:
30 input=name
31 Raster map to be reclassified
32
33 output=name
34 Name for output raster map
35
36 rules=name
37 File containing reclass rules
38
39 title=string
40 Title for the resulting raster map
41
43 r.reclass creates an output map layer based on an input raster map
44 layer. The output map layer will be a reclassification of the input
45 map layer based on reclass rules input to r.reclass, and can be treated
46 in much the same way that raster maps are treated. A TITLE for the
47 output map layer may be (optionally) specified by the user.
48
49 The reclass rules are read from standard input (i.e., from the key‐
50 board, redirected from a file, or piped through another program).
51
52 Before using r.reclass the user must know the following: The new cate‐
53 gories desired; and, which old categories fit into which new cate‐
54 gories. The names of the new categories.
55
57 Suppose we want to reclassify the raster map layer roads, consisting of
58 five categories, into the three new categories: paved roads, unpaved
59 roads, and railroad tracks. The user is asked whether the reclass ta‐
60 ble is to be established with each category value initially set to 0,
61 or with each category value initially set to its own value. A screen
62 like that shown below then appears, listing the categories of the roads
63 raster map layer to be reclassified and prompting the user for the new
64 category values to be assigned them.
65
66
67 ENTER NEW CATEGORY NUMBERS FOR THESE CATEGORIES
68 OLD CATEGORY NAME OLD NEW
69 NUM NUM
70 no data 0 0___
71 Hard Surface, 2 lanes 1 0___
72 Loose Surface, 1 lane 2 0___
73 Improved Dirt 3 0___
74 Unimproved Dirt Trail 4 0___
75 Railroad, single track 5 0___
76 AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE
77 (OR <Ctrl-C> TO CANCEL)
78 In the following screen the new category values have been entered
79 beside the appropriate old category names. Cells assigned category
80 values 2, 3, and 4 in the old raster map layer are now assigned the new
81 category value 2 in the reclassed map; cell data formerly assigned to
82 category value 5 in the old raster map map are now assigned the new
83 category value 3 in the reclassed map.
84 ENTER NEW CATEGORY NUMBERS FOR THESE CATEGORIES
85 OLD CATEGORY NAME OLD NEW
86 NUM NUM
87 no data 0 0___
88 Hard Surface, 2 lanes 1 1___
89 Loose Surface, 1 lane 2 2___
90 Improved Dirt 3 2___
91 Unimproved Dirt Trail 4 2___
92 Railroad, single track 5 3___
93 AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE
94 (OR <Ctrl-C> TO CANCEL)
95 Hitting the escape key will bring up the following screen, which
96 prompts the user to enter a new TITLE and category label for the newly
97 reclassed categories.
98 ENTER NEW CATEGORY NAMES FOR THESE CATEGORIES
99 TITLE: Roads Reclassified
100 CAT NEW CATEGORY NAME
101 NUM
102 0 no data
103 1 Paved Roads
104 2 Unpaved Roads
105 3 Railroad, single track
106 AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE
107 (OR <Ctrl-C> TO CANCEL)
108 Based upon the information supplied by the user in the above sample
109 screens, the new output map, supporting category, color, history, and
110 header files are created.
111
113 In non-interactive program use, the names of an input map, output map,
114 and output map TITLE are given on the command line. However, the
115 reclass rules are still read from standard input (i.e., from the key‐
116 board, redirected from a file, or piped through another program).
117
118 Once the user has specified an input raster map layer, output map layer
119 name, and (optionally) output map layer TITLE by typing r.reclass
120 input=name output=name [TITLE=name]
121
122 Each line of input must have the following format:
123 input_categories=output_category [label]
124
125 where the input lines specify the category values in the input raster
126 map layer to be reclassified to the new output_category category value.
127 Specification of a label to be associated with the new output map layer
128 category is optional. If specified, it is recorded as the category
129 label for the new category value. The equal sign = is required. The
130 input_category(ies) may consist of single category values or a range of
131 such values in the format "low thru high." The word "thru" must be
132 present.
133
134 To include all (remaining) values the asterix "*" can be used. This
135 rule has to be set as last rule. No further rules are accepted after
136 setting this rule.
137
138 No data have to be spcified with NULL.
139
140 A line containing only the word end terminates the input.
141
143 The following examples may help clarify the reclass rules.
144
145
146 1. This example reclassifies categories 1, 2 and 3 in the input
147 raster map layer "roads" to category 1 with category label "good
148 quality" in the output map layer, and reclassifies input raster
149 map layer categories 4 and 5 to category 2 with the label "poor
150 quality" in the output map layer.
151 1 2 3 = 1 good quality
152 4 5 = 2 poor quality
153
154
155 2. This example reclassifies input raster map layer categories 1 thru
156 10 to output map layer category 1, input map layer categories 11 thru
157 20 to output map layer category 2, and input map layer categories 21
158 thru 30 to output map layer category 3, all without labels. The range
159 from 30 to 40 is reclassified as NULL.
160 1 thru 10 = 1
161 11 thru 20 = 2
162 21 thru 30 = 3
163 30 thru 40 = NULL
164
165 3. Subsequent rules override previous rules. Therefore, the below
166 example reclassifies input raster map layer categories 1 thru 19 and 51
167 thru 100 to category 1 in the output map layer, input raster map layer
168 categories 20 thru 24 and 26 thru 50 to the output map layer category
169 2, and input raster map layer category 25 to the output category 3.
170 1 thru 100 = 1 poor quality
171 20 thru 50 = 2 medium quality
172 25 = 3 good quality
173
174 4. This example reclassifies categories 1, 3 and 5 in the input raster
175 map layer to category 1 with category label "poor quality" in the out‐
176 put map layer, and reclassifies input raster map layer categories 2, 4,
177 and 6 to category 2 with the label "good quality" in the output map
178 layer. All other values are reclassified to NULL.
179 1 3 5 = 1 poor quality
180 2 4 6 = 2 good quality
181 * = NULL
182
183
184 5. The previous example could also have been entered as:
185 1 thru 19 51 thru 100 = 1 poor quality
186 20 thru 24 26 thru 50 = 2 medium quality
187 25 = 3 good quality
188 or as:
189 1 thru 19 = 1 poor quality
190 51 thru 100 = 1
191 20 thru 24 = 2
192 26 thru 50 = 2 medium quality
193 25 = 3 good quality
194
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
199 becomes the label for that category. In this case the labels are
200 assigned exactly as in the two previous examples.
201
203 In fact, the r.reclass program does not generate any new raster map
204 layers (in the interests of disk space conservation). Instead, a
205 reclass table is stored which will be used to reclassify the original
206 raster map layer each time the new (reclassed) map name is requested.
207 As far as the user (and programmer) is concerned, that raster map has
208 been created. Also note that although the user can generate a
209 r.reclass map which is based on another r.reclass map, the new
210 r.reclass map map will be stored in GRASS as a reclass of the original
211 raster map on which the first reclassed map was based. Therefore,
212 while GRASS allows the user to provide r.reclass map layer information
213 which is based on an already reclassified map (for the user's conve‐
214 nience), no r.reclass map layer (i.e., reclass table) will ever be
215 stored as a r.reclass of a r.reclass.
216
217 To convert a reclass map to a regular raster map layer, set your geo‐
218 graphic region settings to match the settings in the header for the
219 reclass map (an ASCII file found under the cellhd directory, or view‐
220 able by running r.resample.
221
222 r.mapcalc can be used to convert a reclass map to a regular raster map
223 layer:
224 r.mapcalc raster_map=reclass_map
225
226
227 where raster_map is the name to be given to the new raster map, and
228 reclass_map is an existing reclass map.
229
231 Because r.reclass generates a table referencing some original raster
232 map layer rather than creating a reclassed raster map layer, a
233 r.reclass map layer will no longer be accessible if the original raster
234 map layer upon which it was based is later removed.
235
236 A r.reclass map is not a true raster map layer. Rather, it is a table
237 of reclassification values which reference the input raster map layer.
238 Therefore, users who wish to retain reclassified map layers must also
239 save the original input raster map layers from which they were gener‐
240 ated. Alternatively r.recode can be used.
241
242 Category values which are not explicitly reclassified to a new value by
243 the user will be reclassified to NULL.
244
246 r.resample, r.rescale, r.recode
247
249 James Westervelt,
250 Michael Shapiro,
251 U.S.Army Construction Engineering Research Laboratory
252
253 Last changed: $Date: 2006-12-13 15:21:43 +0100 (Wed, 13 Dec 2006) $
254
255 Full index
256
257 © 2003-2008 GRASS Development Team
258
259
260
261GRASS 6.3.0 r.reclass(1)