The reclass rules are read from standard input (i.e., from the keyboard, redirected from a file, or piped through another program).
The program will be run non-interactively if the user specifies the name of the raster map layer to be reclassified, the name of an output layer to hold reclass rules, and (optionally) the name of a TITLE for the output map:
After the user types in the above information on the command line, the program will (silently) prompt the user for reclass rules to be applied to the input map layer categories. The form of these rules is described in further detail in the sections on non-interactive program use reclass rules and examples, below.
Alternately, the user can simply type r.reclass on the command line, without program arguments. In this case, the user will be prompted for all needed inputs.
Before using r.reclass one must know the following:
ENTER NEW CATEGORY NUMBERS FOR THESE CATEGORIES OLD CATEGORY NAME OLD NEW NUM NUM no data 0 0___ Hard Surface, 2 lanes 1 0___ Loose Surface, 1 lane 2 0___ Improved Dirt 3 0___ Unimproved Dirt Trail 4 0___ Railroad, single track 5 0___ AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE (OR <Ctrl-C> TO CANCEL)In the following screen the new category values have been entered beside the appropriate old category names. Cells assigned category values 2, 3, and 4 in the old raster map layer are now assigned the new category value 2 in the reclassed map; cell data formerly assigned to category value 5 in the old raster map map are now assigned the new category value 3 in the reclassed map.
ENTER NEW CATEGORY NUMBERS FOR THESE CATEGORIES OLD CATEGORY NAME OLD NEW NUM NUM no data 0 0___ Hard Surface, 2 lanes 1 1___ Loose Surface, 1 lane 2 2___ Improved Dirt 3 2___ Unimproved Dirt Trail 4 2___ Railroad, single track 5 3___ AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE (OR <Ctrl-C> TO CANCEL)Hitting the escape key <ESC> will bring up the following screen, which prompts the user to enter a new TITLE and category label for the newly reclassed categories.
ENTER NEW CATEGORY NAMES FOR THESE CATEGORIES TITLE: Roads Reclassified CAT NEW CATEGORY NAME NUM 0 no data 1 Paved Roads 2 Unpaved Roads 3 Railroad, single track AFTER COMPLETING ALL ANSWERS, HIT <ESC> TO CONTINUE (OR <Ctrl-C> TO CANCEL)Based upon the information supplied by the user in the above sample screens, the new output map, supporting category, color, history, and header files are created.
Once the user has specified an input raster map layer, output map layer name, and (optionally) output map layer TITLE by typing
where the input lines specify the category values in the input raster map layer to be reclassified to the new output_category category value. Specification of a label to be associated with the new output map layer category is optional. If specified, it is recorded as the category label for the new category value. The equal sign = is required. The input_category(ies) may consist of single category values or a range of such values in the format "low thru high." The word "thru" must be present.
To include all (remaining) values the asterix "*" can be used. This rule has to be set as last rule. No further rules are accepted after setting this rule.
No data have to be spcified with NULL.
A line containing only the word end terminates the input.
1 3 5 = 1 poor quality 2 4 6 = 2 good quality
1 thru 10 = 1 11 thru 20 = 2 21 thru 30 = 3 30 thru 40 = NULL
1 thru 100 = 1 poor quality 20 thru 50 = 2 medium quality 25 = 3 good quality
1 3 5 = 1 poor quality 2 4 6 = 2 good quality * = NULL
1 thru 19 51 thru 100 = 1 poor quality 20 thru 24 26 thru 50 = 2 medium quality 25 = 3 good qualityor as:
1 thru 19 = 1 poor quality 51 thru 100 = 1 20 thru 24 = 2 26 thru 50 = 2 medium quality 25 = 3 good quality
The final example was given to show how the labels are handled. If a new category value appears in more than one rule (as is the case with new category values 1 and 2), the last label which was specified becomes the label for that category. In this case the labels are assigned exactly as in the two previous examples.
To convert a reclass map to a regular raster map layer, set your geographic region settings to match the settings in the header for the reclass map (an ASCII file found under the cellhd directory, or viewable by running r.support) and then run r.resample.
r.mapcalc can also be used to convert a reclass map to a regular raster map layer:
where raster_map is the name to be given to the new raster map, and reclass_map is an existing reclass map.
A r.reclass map is not a true raster map layer. Rather, it is a table of reclassification values which reference the input raster map layer. Therefore, users who wish to retain reclassified map layers must also save the original input raster map layers from which they were generated.
Category values which are not explicitly reclassified to a new value by the user will be reclassified to 0.