r.infer commands (conditions and consequences) are typed into a file by the user using a system editor like vi, and then input to r.infer as the rulesfile named on the command line. The results are used to generate a new raster map layer named infer in the user's current mapset. This program performs analyses similar to r.combine, but uses a (possibly) more pleasing syntax and approach.
Alternately, the user can simply type r.infer on the command line, without program arguments. In this case, the user will be prompted for the needed parameter value and flag settings using the standard GRASS parser interface.
COMMANDS AND STATEMENTS The following commands are available in r.infer: Command | Aliases | Followed By | Such As -----------+-----------+---------------------+---------------------- IFMAP | ANDIFMAP | cellmap cat# | geology 2 | ANDMAP | | -----------+-----------+---------------------+---------------------- IFNOTMAP | ANDNOTMAP | cellmap cat# | geology 2 -----------+-----------+---------------------+---------------------- THENMAPHYP | | cat# [statement] | 3 nice vacation spot -----------+-----------+---------------------+---------------------- THEN | | statement | No sandstone | | condition | -----------+-----------+---------------------+---------------------- IF | AND | predefined | No sandstone | ANDIF | statement condition |These five commands may be used to formulate statements with functions ranging from a simple reclassification to a more complex expert system type application. Statements are composed of one or more conditions followed by one or more hypotheses and/or conclusions. The use of aliases is provided to allow for the use of a command which has an English meaning consistent with the logic at that point.
Following is a description of each of the five commands. The map layers used in the examples are in the Spearfish sample data base.
example: IFMAP geology 4 5
example: IFNOTMAP owner 2
THENMAPHYP Map conclusion
It is important to realize that r.infer runs through the conditions stated in the named rulesfile one cell at a time, moving from the top of the raster input file to the bottom of the raster input file. As soon as the cell currently being examined by r.infer satisfies a set of conditions, it is assigned a category value in the new map layer infer. r.infer does NOT check to see if that same cell satisfies other conditions named further down in the input file, too. Instead, it moves on to the next cell, and begins anew with the conditions named at the top of the input file. Essentially, this means that conclusions made higher-up in the input file have precedence over conditions named further down in the input file.
example:
IFMAP density 1
THENMAPHYP 1 no trees
In the above example, all cells having a category value of 1 (non-forest) in the map layer density, are assigned a category value of 1 in the resultant map layer infer. The trailing text "no trees" is entered into the category support file for category 1 in the new map layer infer.
example:
IFMAP elevation.255 170-255
ANDIFMAP density 3 4
THEN high elevation with trees
!
IF high elevation with trees
ANDIFMAP owner 2
THENMAPHYP 1 this is the place
The above example queries each cell for the presence of both elevations greater than 1580 meters (i.e., for elevation.255 category values 170-255) and a medium to high density of trees (i.e., density category values 3 4). All areas (i.e., cells) that satisfy these criteria are assigned to the hypothesis "high elevation with trees." The "!" simply tells r.infer to ignore whatever appears on that line (a comment statement), and is used here for readability.
The IF statement then references cells having "high elevation with trees" (i.e., those cells that satisfied both of the above conditions named by the IFMAP and ANDIFMAP statements). If a cell both has "high elevations with trees" and owner map layer category 2 (areas owned by the Forest Service), it is assigned by the THENMAPHYP statement to category 1 in the new map layer infer. The trailing text "this is the place" is automatically entered into the category support file for the new map infer. Cells failing to meet all of the conditions stated in this input file will be assigned category 0 in the new map layer infer.
g.rename, r.combine, r.mapcalc, r.weight, and parser
Special recognition goes to:
George W. Hageman
SOFTMAN Enterprises
P.O. Box 11234
Boulder, Colorado 80301
Daniel S. Cox
In Touch
796 West Peachtree St. NE
Atlanta, GA 30308
Mr. Hageman, in the spring of 1986, submitted an inference engine to the UNIX network. Mr. Cox reworked the code submitting an new version shortly thereafter. It is this code that forms the guts of r.infer.