The MASK is applied when reading an existing GRASS raster map, for example when used as an input map in a module. The MASK will block out certain areas of a raster map from analysis and/or display, by "hiding" them from sight of other GRASS modules. Data falling within the boundaries of the MASK can be modified and operated upon by other GRASS raster modules; data falling outside the MASK is treated as if it were NULL.
By default, r.mask converts any non-NULL value in the input map, including zero, to 1. All these areas will be part of the MASK (see the notes for more details). To only convert specific values (or range of values) to 1 and the rest to NULL, use the maskcats parameter.
Because the MASK created with r.mask is actually only a reclass map named "MASK", it can be copied, renamed, removed, and used in analyses, just like other GRASS raster map layers.
The user should be aware that a MASK remains in place until a user renames it
to something other than "MASK", or removes it. To remove a mask and restore
raster operations to normal (i.e., all cells of the current region), remove the
MASK by setting the -r remove MASK flag (r.mask -r
).
Alternatively, a mask can be removed using g.remove or by renaming it
to any other name with g.rename.
r.mask uses r.reclass to create a reclassification of an
existing raster map and name it MASK
. A reclass map takes up less
space, but is affected by any changes to the underlying map from which it was
created. The user can select category values from the input raster to use in the
MASK with the maskcats parameter; if r.mask is run from the
command line, the category values listed in maskcats must be quoted
(see example below). Note that the maskcats can only be used if the
input map is an integer map.
NULL
or 0
will replace data with
NULL, while cells containing other values will allow data to pass through
unaltered. This means that:
If a binary map with [0,1] values is used as input in r.mask, all raster cells with 0 and 1 will be part of the MASK. This is because r.mask converts all non-NULL cells to 1.
r.mapcalc -s "map1 = round(rand(0,1))" r.mask raster=map1
r.mapcalc -s "map2 = round(rand(0,1))" g.copy raster=map2,MASK
r.mapcalc -s "map3 = rand(0.0,1.0)" r.mask raster=map3
r.mapcalc -s "map4 = rand(0.0,1.0)" g.copy raster=map4,MASK
Create a raster mask, for constraining the calculation of univariate statistics of the elevation values for "lakes":
# set computation region to lakes raster map g.region raster=lakes -p # use lakes as MASK r.mask raster=lakes # get statistics for elevation pixels of lakes: r.univar elevation
r.mask -r
g.region raster=geology_30m -p r.category geology_30m d.mon wx0 d.rast geology_30m r.mask raster=geology_30m maskcats="217 thru 720" d.mon wx0 d.rast geology_30m
Available at: r.mask source code (history)
Latest change: Tuesday Dec 17 20:17:20 2024 in commit: d962e90c026708a4815ea2b9f46c0e84c17de22d
Main index | Raster index | Topics index | Keywords index | Graphical index | Full index
© 2003-2024 GRASS Development Team, GRASS GIS 8.4.1dev Reference Manual