1r.mask(1) GRASS GIS User's Manual r.mask(1)
2
3
4
6 r.mask - Creates a MASK for limiting raster operation.
7
9 raster, mask
10
12 r.mask
13 r.mask --help
14 r.mask [-ir] [raster=name] [maskcats=string] [vector=name]
15 [layer=string] [cats=range] [where=sql_query] [--overwrite]
16 [--help] [--verbose] [--quiet] [--ui]
17
18 Flags:
19 -i
20 Create inverse mask
21
22 -r
23 Remove existing mask (overrides other options)
24
25 --overwrite
26 Allow output files to overwrite existing files
27
28 --help
29 Print usage summary
30
31 --verbose
32 Verbose module output
33
34 --quiet
35 Quiet module output
36
37 --ui
38 Force launching GUI dialog
39
40 Parameters:
41 raster=name
42 Name of raster map to use as mask
43
44 maskcats=string
45 Raster values to use for mask
46 Format: 1 2 3 thru 7 *
47 Default: *
48
49 vector=name
50 Name of vector map to use as mask
51 Or data source for direct OGR access
52
53 layer=string
54 Layer number or name (vector)
55 Vector features can have category values in different layers. This
56 number determines which layer to use. When used with direct OGR
57 access this is the layer name.
58 Default: 1
59
60 cats=range
61 Category values (vector)
62 Example: 1,3,7-9,13
63
64 where=sql_query
65 WHERE conditions of SQL statement without ’where’ keyword (vector)
66 Example: income < 1000 and population >= 10000
67
69 r.mask - Facilitates creation of a raster "MASK" map to control raster
70 operations.
71
72 The MASK is only applied when reading an existing GRASS raster map, for
73 example when used in a module as an input map. The MASK will block out
74 certain areas of a raster map from analysis and/or display, by "hiding"
75 them from sight of other GRASS modules. Data falling within the bound‐
76 aries of the MASK can be modified and operated upon by other GRASS
77 raster modules; data falling outside the MASK is treated as if it were
78 NULL.
79
80 Because the MASK is actually only a reclass map named "MASK", it can be
81 copied, renamed, removed, and used in analyses, just like other GRASS
82 raster map layers. The user should be aware that a MASK remains in
83 place until a user renames it to something other than "MASK", or
84 removes it using "r.mask -r" or g.remove.
85
86 Grid cells in the MASK map containing 0 or NULL will replace data with
87 NULL, while cells containing other values will allow data to pass
88 through unaltered.
89
90 To restore raster operations to normal (i.e., all cells of the current
91 region), remove the MASK file by setting the -r remove MASK flag. In
92 this case, a dummy value must also be given for the input parameter. A
93 MASK also can be removed by using g.remove or by renaming it to any
94 other name with g.rename.
95
97 The above method for specifying a "mask" may seem counterintuitive.
98 Areas inside the MASK are not hidden; areas outside the MASK will be
99 ignored until the MASK file is removed.
100
101 The MASK is read as an integer map. If MASK is actually a float‐
102 ing-point map, the values will be converted to integers using the map’s
103 quantisation rules (this defaults to round-to-nearest, but can be
104 changed with r.quant).
105
106 r.mask uses r.reclass to create a reclassification of an existing
107 raster map and name it MASK. A reclass map takes up less space, but is
108 affected by any changes to the underlying map from which it was cre‐
109 ated. The user can select category values from the input raster to use
110 in the MASK with the maskcats parameter; if r.mask is run from the com‐
111 mand line, the category values listed in maskcats must be quoted (see
112 example below).
113
114 Somewhat similar program functions to those performed by r.mask can be
115 done using r.mapcalc, g.region, and other commands.
116
118 The examples are based on the North Carolina sample dataset.
119
120 Create a raster mask, for contraining the calculation of univariate
121 statistics of the elevation values for "lakes":
122 # set computation region to lakes raster map
123 g.region raster=lakes -p
124 # use lakes as MASK
125 r.mask raster=lakes
126 # get statistics for elevation pixels of lakes:
127 r.univar elevation
128 Remove the raster mask ("MASK" map) with the -r flag:
129 r.mask -r
130 Creating a mask from selected categories in the North Carolina ’geol‐
131 ogy_30m’ raster map:
132 g.region raster=geology_30m -p
133 r.category geology_30m
134 d.mon wx0
135 d.rast geology_30m
136 r.mask raster=geology_30m maskcats="217 thru 720"
137 d.mon wx0
138 d.rast geology_30m
139
141 g.region, r.mapcalc, r.reclass, g.remove, g.rename
142
144 Michael Barton, Arizona State University
145
147 Available at: r.mask source code (history)
148
149 Main index | Raster index | Topics index | Keywords index | Graphical
150 index | Full index
151
152 © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
153
154
155
156GRASS 7.8.5 r.mask(1)