If you find this document usefull, please consider ordering a printed hardcopy!


Subsections


6 Methods for manipulating rastermaps


1 Reclassification

When classifying a rastermap a new attribute table for the rastermap is created. The actual map remains unaffected. The memory requirement is small because this only involves a table. The source map is, however, the necessary base map for the new classified map.

The module r.reclass can be operated interactively or via the command-line prompt. The necessary classification standards should be saved in a file, which is indicated at the time of execution of the module.

The exact command syntax should be looked up in the detailed description g.manual r.reclass before using it. As an example, assume the roadmap roads in the Spearfish region needs to be reclassified. Instead of the five available categories only a specification of "good" or "bad" condition is needed:

# CLASSIFICATION BEFORE:
r.report roads
|1|interstate
|2|primary highway, hard surface
|3|secondary highway, hard surface
|4|light-duty road, improved surface
|5|unimproved road
|*|no data

# RECLASSIFICATION:
r.reclass in=roads out=roads.rcl
Enter rule(s), "end" when done, "help" if you need it
Data range is 1 to 5
> 1 2 3 = 1 good condition
> 4 5 = 2 bad condition
> end

# CLASSIFICATION AFTER: 
r.report roads.rcl 
|1|good condition 
|2|bad condition 
|*|no data

The module r.mapcalc offers the possibility of creating an "independent" map again:

g.region rast=roads.rcl -p
r.mapcalc "newmap=roads.rcl"


2 Masking

The masking of image ranges can be very helpful in the forefront of raster operations. Masks that are set influence all successive raster analyses - just like the currently set region or resolution.

Basically, only a map with the name MASK (in upper case) is considered as mask in the respective mapset by the raster modules. For this map no analysis will be made for areas where the pixel value NoData (NULL) is assigned in the MASK. All other areas are used during the calculation.

A mask can be created in many different ways. If an appropriate map is already available it can simply be copied or renamed.

g.copy rast=Mask,MASK
g.rename rast=Mask,MASK

The module r.mapcalc offers an other possibility. For a potential mask it allows the extraction of pixel values, which have to operate as a mask (see chapter 15).

Example using the Spearfish dataset

You have a landuse map landuse and you only want to analyse this map in areas, where the ground height lies above 1200 m. In order to determine this limit choose the elevation map elevation.10m, which you are able to convert into a mask via the module r.mapcalc. The creation of the mask could be as follows:

g.region rast=elevation.10m -p 
r.mapcalc "mask1200=if(elevation.10m > 1200.0,1,null())"
g.copy rast=mask1200,MASK

Only raster data are analyzed in those ranges, for which a ``1'' is indicated in the MASK map as long as the map MASK is available in the current mapset. This should be verified by displaying the map:

d.rast elevation.10m
d.rast -o roads

During any project, the availability of a mask in the command line can be recognized by the reappearing text [Raster MASK present].

For deleting the MASK the command g.remove is used. Afterwards, the total current 'region' is involved in the analysis again:

g.remove rast=MASK

If the created mask is supposed to be used again later, it can also be renamed in order to deactivate it.

g.rename rast=MASK,Mask


If you find this document usefull, please consider ordering a printed hardcopy!


© 2005, GDF Hannover bR - Solutions for spatial data analysis and remote sensing
Last modified: 29-08-2005