3
The <em>g.region</em> module allows the user to manage the
4
settings of the current geographic region. These regional
5
boundaries can be set by the user directly and/or set from
6
a region definition file (stored under the
7
<kbd>windows</kbd> directory in the user's current
8
mapset). The user can create, modify, and store as many
9
geographic region definitions as desired for any given
10
mapset. However, only one of these geographic region
11
definitions will be current at any given moment, for a
12
specified mapset; i.e., GRASS programs that respect the
13
geographic region settings will use the current geographic
22
<dd>In GRASS, a <em>region</em> refers to a geographic area
23
with some defined boundaries, based on a specific map
24
coordinate system and map projection. Each region also has
25
associated with it the specific east-west and north-south
26
resolutions of its smallest units (rectangular units called
30
The region's boundaries are given as the northernmost,
31
southernmost, easternmost, and westernmost points that
32
define its extent (cell edges). The north and south boundaries
33
are commonly called <em>northings</em>, while the east and west
34
boundaries are called <em>eastings</em>.
37
The region's cell resolution defines the size of the
38
smallest piece of data recognized (imported, analyzed,
39
displayed, stored, etc.) by GRASS modules affected by the
40
current region settings. The north-south and east-west cell
41
resolutions need not be the same, thus allowing non-square
44
<p>Typically all raster and display modules are affected by the current
45
region settings, but not vector modules.
46
Some special modules diverge from this rule, for example raster import
47
modules and <em>v.in.region</em>.
50
<dt><b>Default Region:</b>
52
<dd>Each GRASS LOCATION has a fixed
53
geographic region, called the default geographic region
54
(stored in the region file <kbd>DEFAULT_WIND</kbd> under
55
the special mapset <kbd>PERMANENT</kbd>), that defines the
56
extent of the data base. While this provides a starting
57
point for defining new geographic regions, user-defined
58
geographic regions need not fall within this geographic
59
region. The current region can be reset to the default region
60
with the <b>-d</b> flag. The default region is initially set
61
when the location is first created and can be reset using the
64
<dt><b>Current Region:</b>
66
<dd>Each mapset has a current geographic region. This
67
region defines the geographic area in which all GRASS
68
displays and raster analyses will be done. Raster data will be
69
resampled, if necessary, to meet the cell resolutions of
70
the current geographic region setting.
72
<dt><b>Saved Regions:</b>
74
<dd>Each GRASS MAPSET may contain any number of
75
pre-defined, and named, geographic regions. These region
76
definitions are stored in the user's current mapset
77
location under the <kbd>windows</kbd> directory (also
78
referred to as the user's saved region definitions).
79
Any of these pre-defined geographic regions
80
may be selected, by name, to become the current geographic
81
region. Users may also access saved region definitions
82
stored under other mapsets in the current location, if
83
these mapsets are included in the user's mapset search
84
path or the '@' operator is used (<tt>region_name@mapset</tt>).
90
After all updates have been applied, the current region's
91
southern and western boundaries are (silently) adjusted so
92
that the north/south distance is a multiple of the
93
north/south resolution and that the east/west distance is a
94
multiple of the east/west resolution.
96
<p>With the <b>-a</b> flag all four boundaries are adjusted
97
to be even multiples of the resolution, aligning the region to the
98
resolution supplied by the user. The default is to
99
align the region resolution to match the region boundaries.
101
<p>The <b>-m</b> flag will report the region resolution in meters. The
102
resolution is calculated by averaging the resolution at the region
103
boundaries. This resolution is calculated by dividing the geodesic
104
distance in meters at the boundary by the number of rows or columns.
105
For example the east / west resolution (ewres) is determined from an
106
average of the geodesic distances at the North and South boundaries
107
divided by the number of columns.
108
<!-- add'l info. include?
109
Print the region resolution in meters (from geodesic). With no other
110
flags the default output format is shell stype (-g). The region resolution
111
represents the center of the map. The resolutions are calculated at the four
112
outside edges, then the two NS edges are averaged and the two EW edges are
113
averaged, the results finally printed.
117
<p>The <b>-p</b> (or <b>-g</b>) option is recognized
118
last. This means that all changes are applied to the
119
region settings before printing occurs.
120
<p>The <b>-g</b> flag prints the current region settings in shell script style.
121
This format can be given back to <em>g.region</em> on its command line.
122
This may also be used to save region settings as shell environment variables
123
with the UNIX eval command, "<tt>eval `g.region -g`</tt>".
126
<h3>Additional parameter information:</h3>
130
<dt><b>zoom=</b><em>name</em>
131
<dd>Shrink current region settings to the smallest region
132
encompassing all non-NULL data in the named raster map
133
layer that fall inside the user's current region. In this
134
way you can tightly zoom in on isolated clumps within a
136
<p>If the user also includes the <b>raster=</b><em>name</em>
137
option on the command line, <b>zoom=</b><em>name</em> will
138
set the current region settings to the smallest region
139
encompassing all non-NULL data in the named <b>zoom</b> map
140
that fall inside the region stated in the cell header for
141
the named <b>raster</b> map.
144
<dt><b>align=</b><em>name</em>
146
<dd>Set the current resolution equal to that of the named
147
raster map, and align the current region to a row and
148
column edge in the named map. Alignment only moves the
149
existing region edges outward to the edges of the next
150
nearest cell in the named raster map - not to the named
151
map's edges. To perform the latter function, use the
152
<b>raster=</b><em>name</em> option.
160
<dt><span class="code"><tt>
161
g.region n=7360100 e=699000
164
<dd> will reset the northing and easting for the current
165
region, but leave the south edge, west edge, and the region
166
cell resolutions unchanged.
169
<dt><span class="code"><tt>
170
g.region n=51:36:05N e=10:10:05E s=51:29:55N w=9:59:55E res=0:00:01
173
<dd> will reset the northing, easting, southing, westing and resolution
174
for the current region, here in DMS latitude-longitude style
175
(decimal degrees and degrees with decimal minutes can also be used).
178
<dt><span class="code"><tt>
179
g.region -dp s=698000
182
<dd> will set the current region from the default region
183
for the GRASS data base location, reset the south edge to
184
698000, and then print the result.
187
<dt><span class="code"><tt>
188
g.region n=n+1000 w=w-500
191
<dd> The n=<em>value</em> may also be specified as a
192
function of its current value: n=n+<em>value</em>
193
increases the current northing, while n=n-<em>value</em>
194
decreases it. This is also true for s=<em>value</em>,
195
e=<em>value</em>, and w=<em>value</em>. In this example
196
the current region's northern boundary is extended by 1000
197
units and the current region's western boundary is
198
decreased by 500 units.
201
<dt><span class="code"><tt>
202
g.region n=s+1000 e=w+1000
205
<dd> This form allows the user to set the region boundary
206
values relative to one another. Here, the northern
207
boundary coordinate is set equal to 1000 units larger than
208
the southern boundary's coordinate value, and the eastern
209
boundary's coordinate value is set equal to 1000 units
210
larger than the western boundary's coordinate value. The
211
corresponding forms s=n-<em>value</em> and
214
w=e-<em>value</em> may be used to set the values of the
215
region's southern and western boundaries, relative to the
216
northern and eastern boundary values.
219
<dt><span class="code"><tt>
220
g.region raster=soils
223
<dd> This form will make the current region settings
224
exactly the same as those given in the cell header file for
225
the raster map layer <em>soils</em>.
229
<dt><span class="code"><tt>
230
g.region raster=soils zoom=soils
233
<dd> This form will first look up the cell header file for
234
the raster map layer <em>soils</em>, use this as the
235
current region setting, and then shrink the region down to
236
the smallest region which still encompasses all non-NULL
237
data in the map layer <em>soils</em>. Note that if the
238
parameter <em>raster=soils</em> were not specified, the
239
zoom would shrink to encompass all non-NULL data values in
240
the soils map that were located within the <i>current region</i>
245
<dt><span class="code"><tt>
246
g.region -up raster=soils
249
<dd> The <b>-u</b> option suppresses the re-setting of the
250
current region definition. This can be useful when it is
251
desired to only extract region information. In this case,
252
the cell header file for the soils map layer is printed
253
without changing the current region settings.
256
<dt><span class="code"><tt>
257
g.region -up zoom=soils save=soils
260
<dd> This will zoom into the smallest region which
261
encompasses all non-NULL soils data values, and save the
262
new region settings in a file to be called <em>soils</em>
263
and stored under the <kbd>windows</kbd> directory in the
264
user's current mapset. The current region settings are not
268
<dt><span class="code"><tt>
269
g.region b=0 t=3000 tbres=200 res3=100
273
<dd> This will define the 3D region for voxel computations.
274
In this example a volume with bottom (0m) to top (3000m)
275
at horizontal resolution (100m) and vertical resolution (200m)
279
<dt><span class="code"><tt>
283
<dd> This will print the current region in the format:
285
<div class="code"><pre>
301
<dt><span class="code"><tt>
305
<dd> This will print the current region and the 3D region (used for voxels)
308
<div class="code"><pre>
332
<dt><span class="code"><tt>
336
<dd> The <b>-g</b> option prints the region in the
337
following script style (key=value) format:
339
<div class="code"><pre>
351
<dt><span class="code"><tt>
355
<dd> The <b>-bg</b> option prints the region in the
356
following script style (key=value) format plus the
357
boundary box in latitude-longitude/WGS84:
359
<div class="code"><pre>
375
<dt><span class="code"><tt>
379
<dd> The <b>-l</b> option prints the region in the
382
<div class="code"><pre>
383
long: -103.86789484 lat: 44.50165890 (north/west corner)
384
long: -103.62895703 lat: 44.49904013 (north/east corner)
385
long: -103.63190061 lat: 44.37303558 (south/east corner)
386
long: -103.87032572 lat: 44.37564292 (south/west corner)
389
Center longitude: 103:44:59.170374W [-103.74977]
390
Center latitude: 44:26:14.439781N [44.43734]
394
<dt><span class="code"><tt>
398
<dd> This will print the current region in the format
399
(latitude-longitude location):
401
<div class="code"><pre>
402
projection: 3 (Latitude-Longitude)
414
Note that the resolution is here reported in meters, not decimal degrees.
418
<p>Usage example of <em>g.region</em> in a shell with external software:<br>
419
<!-- why not 'v.in.ogr spatial=' ?? -->
420
Extract spatial subset of external vector map 'soils.shp' to new external
421
vector map 'soils_cut.shp' using the OGR 'ogr2ogr' tool:<br>
423
<div class="code"><pre>
425
ogr2ogr -spat $w $s $e $n soils_cut.shp soils.shp
428
This requires that the location/SHAPE file projection match.
431
<p>Usage example of <em>g.proj</em> and <em>g.region</em> in a shell with external software:<br>
432
Extract spatial subset of external raster map 'p016r035_7t20020524_z17_nn30.tif'
433
to new external raster map'p016r035_7t20020524_nc_spm_wake_nn30.tif using the GDAL
436
<div class="code"><pre>
438
gdalwarp -t_srs "`g.proj -wf`" -te $w $s $e $n \
439
p016r035_7t20020524_z17_nn30.tif \
440
p016r035_7t20020524_nc_spm_wake_nn30.tif
443
Here the input raster map does not have to match the location
444
projection since it is reprojected on the fly.
451
<a href="g.access.html">g.access</a>,
452
<a href="g.mapsets.html">g.mapsets</a>,
453
<a href="g.proj.html">g.proj</a>,
454
<a href="g.setproj.html">g.setproj</a><br>
455
Environment variables: <a href="variables.html#internal">GRASS_REGION and WIND_OVERRIDE</a>
462
U.S.Army Construction Engineering
465
<p><i>Last changed: $Date: 2014-12-19 22:55:37 +0100 (Fri, 19 Dec 2014) $</i>