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