123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475 |
- <h2>DESCRIPTION</h2>
- The <em>g.region</em> module allows the user to manage the
- settings of the current geographic region. These regional
- boundaries can be set by the user directly and/or set from
- a region definition file (stored under the
- <kbd>windows</kbd> directory in the user's current
- mapset). The user can create, modify, and store as many
- geographic region definitions as desired for any given
- mapset. However, only one of these geographic region
- definitions will be current at any given moment, for a
- specified mapset; i.e., GRASS programs that respect the
- geographic region settings will use the current geographic
- region settings.
- <h2>DEFINITIONS</h2>
- <dl>
- <dt><b>Region:</b>
- <dd>In GRASS, a <em>region</em> refers to a geographic area
- with some defined boundaries, based on a specific map
- coordinate system and map projection. Each region also has
- associated with it the specific east-west and north-south
- resolutions of its smallest units (rectangular units called
- "cells").
- <p>
- The region's boundaries are given as the northernmost,
- southernmost, easternmost, and westernmost points that
- define its extent (cell edges). The north and south boundaries
- are commonly called <em>northings</em>, while the east and west
- boundaries are called <em>eastings</em>.
- <p>
- The region's cell resolution defines the size of the
- smallest piece of data recognized (imported, analyzed,
- displayed, stored, etc.) by GRASS modules affected by the
- current region settings. The north-south and east-west cell
- resolutions need not be the same, thus allowing non-square
- data cells to exist.
- <p>Typically all raster and display modules are affected by the current
- region settings, but not vector modules.
- Some special modules diverge from this rule, for example raster import
- modules and <em>v.in.region</em>.
- <dt><b>Default Region:</b>
- <dd>Each GRASS LOCATION has a fixed
- geographic region, called the default geographic region
- (stored in the region file <kbd>DEFAULT_WIND</kbd> under
- the special mapset <kbd>PERMANENT</kbd>), that defines the
- extent of the data base. While this provides a starting
- point for defining new geographic regions, user-defined
- geographic regions need not fall within this geographic
- region. The current region can be reset to the default region
- with the <b>-d</b> flag. The default region is initially set
- when the location is first created and can be reset using the
- <b>-s</b> flag.
- <dt><b>Current Region:</b>
- <dd>Each mapset has a current geographic region. This
- region defines the geographic area in which all GRASS
- displays and raster analyses will be done. Raster data will be
- resampled, if necessary, to meet the cell resolutions of
- the current geographic region setting.
- <dt><b>Saved Regions:</b>
- <dd>Each GRASS MAPSET may contain any number of
- pre-defined, and named, geographic regions. These region
- definitions are stored in the user's current mapset
- location under the <kbd>windows</kbd> directory (also
- referred to as the user's saved region definitions).
- Any of these pre-defined geographic regions
- may be selected, by name, to become the current geographic
- region. Users may also access saved region definitions
- stored under other mapsets in the current location, if
- these mapsets are included in the user's mapset search
- path or the '@' operator is used (<tt>region_name@mapset</tt>).
- </dl>
- <h2>NOTES</h2>
- After all updates have been applied, the current region's
- southern and western boundaries are (silently) adjusted so
- that the north/south distance is a multiple of the
- north/south resolution and that the east/west distance is a
- multiple of the east/west resolution.
- <p>With the <b>-a</b> flag all four boundaries are adjusted
- to be even multiples of the resolution, aligning the region to the
- resolution supplied by the user. The default is to
- align the region resolution to match the region boundaries.
- <p>The <b>-m</b> flag will report the region resolution in meters. The
- resolution is calculated by averaging the resolution at the region
- boundaries. This resolution is calculated by dividing the geodesic
- distance in meters at the boundary by the number of rows or columns.
- For example the east / west resolution (ewres) is determined from an
- average of the geodesic distances at the North and South boundaries
- divided by the number of columns.
- <!-- add'l info. include?
- Print the region resolution in meters (from geodesic). With no other
- flags the default output format is shell stype (-g). The region resolution
- represents the center of the map. The resolutions are calculated at the four
- outside edges, then the two NS edges are averaged and the two EW edges are
- averaged, the results finally printed.
- -->
- <p>The <b>-p</b> (or <b>-g</b>) option is recognized
- last. This means that all changes are applied to the
- region settings before printing occurs.
- <p>The <b>-g</b> flag prints the current region settings in shell script style.
- This format can be given back to <em>g.region</em> on its command line.
- This may also be used to save region settings as shell environment variables
- with the UNIX eval command, "<tt>eval `g.region -g`</tt>".
- <p>With <b>-u</b> flag current region is not updated even if one or more
- options for changing region is used (<b>res=</b>, <b>raster=</b>, etc).
- This can be used for example to print modified region values for further use
- without actually modifying the current region.
- Similarly, <b>-o</b> flag forces to update current region file even when e.g., only
- printing was specified. Flag <b>-o</b> was added in GRASS GIS version 8 to simulate
- <em>g.region</em> behavior in prior versions when current region file was
- always updated unless <b>-u</b> was specified.
- <h3>Additional parameter information:</h3>
- <dl>
- <dt><b>zoom=</b><em>name</em>
- <dd>Shrink current region settings to the smallest region
- encompassing all non-NULL data in the named raster map
- layer that fall inside the user's current region. In this
- way you can tightly zoom in on isolated clumps within a
- bigger map.
- <p>If the user also includes the <b>raster=</b><em>name</em>
- option on the command line, <b>zoom=</b><em>name</em> will
- set the current region settings to the smallest region
- encompassing all non-NULL data in the named <b>zoom</b> map
- that fall inside the region stated in the cell header for
- the named <b>raster</b> map.
- <dt><b>align=</b><em>name</em>
- <dd>Set the current resolution equal to that of the named
- raster map, and align the current region to a row and
- column edge in the named map. Alignment only moves the
- existing region edges outward to the edges of the next
- nearest cell in the named raster map - not to the named
- map's edges. To perform the latter function, use the
- <b>raster=</b><em>name</em> option.
- </dl>
- <h2>EXAMPLES</h2>
- <h3>Printing extent and raster resolution in 2D and 3D</h3>
- <dl>
- <dt><span class="code"><tt>
- g.region -p
- </tt></span>
- <dd> This will print the current region in the format:
- <div class="code"><pre>
- projection: 1 (UTM)
- zone: 13
- datum: nad27
- ellipsoid: clark66
- north: 4928000
- south: 4914000
- west: 590000
- east: 609000
- nsres: 20
- ewres: 20
- rows: 700
- cols: 950
- </pre></div>
- <p>
- <dt><span class="code"><tt>
- g.region -p3
- </tt></span>
- <dd> This will print the current region and the 3D region (used for voxels)
- in the format:
- <div class="code"><pre>
- projection: 1 (UTM)
- zone: 13
- datum: nad27
- ellipsoid: clark66
- north: 4928000
- south: 4914000
- west: 590000
- east: 609000
- top: 1.00000000
- bottom: 0.00000000
- nsres: 20
- nsres3: 20
- ewres: 20
- ewres3: 20
- tbres: 1
- rows: 700
- rows3: 700
- cols: 950
- cols3: 950
- depths: 1
- </pre></div>
- <p>
- <dt><span class="code"><tt>
- g.region -g
- </tt></span>
- <dd> The <b>-g</b> option prints the region in the
- following script style (key=value) format:
- <div class="code"><pre>
- n=4928000
- s=4914000
- w=590000
- e=609000
- nsres=20
- ewres=20
- rows=700
- cols=950
- </pre></div>
- <p>
- <dt><span class="code"><tt>
- g.region -bg
- </tt></span>
- <dd> The <b>-bg</b> option prints the region in the
- following script style (key=value) format plus the
- boundary box in latitude-longitude/WGS84:
- <div class="code"><pre>
- n=4928000
- s=4914000
- w=590000
- e=609000
- nsres=20
- ewres=20
- rows=700
- cols=950
- LL_W=-103.87080682
- LL_E=-103.62942884
- LL_N=44.50164277
- LL_S=44.37302019
- </pre></div>
- <p>
- <dt><span class="code"><tt>
- g.region -l
- </tt></span>
- <dd> The <b>-l</b> option prints the region in the
- following format:
- <div class="code"><pre>
- long: -103.86789484 lat: 44.50165890 (north/west corner)
- long: -103.62895703 lat: 44.49904013 (north/east corner)
- long: -103.63190061 lat: 44.37303558 (south/east corner)
- long: -103.87032572 lat: 44.37564292 (south/west corner)
- rows: 700
- cols: 950
- Center longitude: 103:44:59.170374W [-103.74977]
- Center latitude: 44:26:14.439781N [44.43734]
- </pre></div>
- <p>
- <dt><span class="code"><tt>
- g.region -pm
- </tt></span>
- <dd> This will print the current region in the format
- (latitude-longitude location):
- <div class="code"><pre>
- projection: 3 (Latitude-Longitude)
- zone: 0
- ellipsoid: wgs84
- north: 90N
- south: 40N
- west: 20W
- east: 20E
- nsres: 928.73944902
- ewres: 352.74269109
- rows: 6000
- cols: 4800
- </pre></div>
- Note that the resolution is here reported in meters, not decimal degrees.
- </dl>
- <h3>Changing extent and raster resolution using values</h3>
- <dl>
- <dt><span class="code"><tt>
- g.region n=7360100 e=699000
- </tt></span>
- <dd> will reset the northing and easting for the current
- region, but leave the south edge, west edge, and the region
- cell resolutions unchanged.
- <p>
- <dt><span class="code"><tt>
- g.region n=51:36:05N e=10:10:05E s=51:29:55N w=9:59:55E res=0:00:01
- </tt></span>
- <dd> will reset the northing, easting, southing, westing and resolution
- for the current region, here in DMS latitude-longitude style
- (decimal degrees and degrees with decimal minutes can also be used).
- <p>
- <dt><span class="code"><tt>
- g.region -dp s=698000
- </tt></span>
- <dd> will set the current region from the default region
- for the GRASS data base location, reset the south edge to
- 698000, and then print the result.
- <p>
- <dt><span class="code"><tt>
- g.region n=n+1000 w=w-500
- </tt></span>
- <dd> The n=<em>value</em> may also be specified as a
- function of its current value: n=n+<em>value</em>
- increases the current northing, while n=n-<em>value</em>
- decreases it. This is also true for s=<em>value</em>,
- e=<em>value</em>, and w=<em>value</em>. In this example
- the current region's northern boundary is extended by 1000
- units and the current region's western boundary is
- decreased by 500 units.
- <p>
- <dt><span class="code"><tt>
- g.region n=s+1000 e=w+1000
- </tt></span>
- <dd> This form allows the user to set the region boundary
- values relative to one another. Here, the northern
- boundary coordinate is set equal to 1000 units larger than
- the southern boundary's coordinate value, and the eastern
- boundary's coordinate value is set equal to 1000 units
- larger than the western boundary's coordinate value. The
- corresponding forms s=n-<em>value</em> and
- <p>
- w=e-<em>value</em> may be used to set the values of the
- region's southern and western boundaries, relative to the
- northern and eastern boundary values.
- </dl>
- <h3>Changing extent and raster resolution using maps</h3>
- <dl>
- <dt><span class="code"><tt>
- g.region raster=soils
- </tt></span>
- <dd> This form will make the current region settings
- exactly the same as those given in the cell header file for
- the raster map layer <em>soils</em>.
- <p>
- <dt><span class="code"><tt>
- g.region raster=soils zoom=soils
- </tt></span>
- <dd> This form will first look up the cell header file for
- the raster map layer <em>soils</em>, use this as the
- current region setting, and then shrink the region down to
- the smallest region which still encompasses all non-NULL
- data in the map layer <em>soils</em>. Note that if the
- parameter <em>raster=soils</em> were not specified, the
- zoom would shrink to encompass all non-NULL data values in
- the soils map that were located within the <i>current region</i>
- settings.
- <p>
- <dt><span class="code"><tt>
- g.region -up raster=soils
- </tt></span>
- <dd> The <b>-u</b> option suppresses the re-setting of the
- current region definition. This can be useful when it is
- desired to only extract region information. In this case,
- the cell header file for the soils map layer is printed
- without changing the current region settings.
- <p>
- <dt><span class="code"><tt>
- g.region -up zoom=soils save=soils
- </tt></span>
- <dd> This will zoom into the smallest region which
- encompasses all non-NULL soils data values, and save the
- new region settings in a file to be called <em>soils</em>
- and stored under the <kbd>windows</kbd> directory in the
- user's current mapset. The current region settings are not
- changed.
- </dl>
- <h3>Changing extent and raster resolution in 3D</h3>
- <dl>
- <dt><span class="code"><tt>
- g.region b=0 t=3000 tbres=200 res3=100
- g.region -p3
- </tt></span>
- <dd> This will define the 3D region for voxel computations.
- In this example a volume with bottom (0m) to top (3000m)
- at horizontal resolution (100m) and vertical resolution (200m)
- is defined.
- </dl>
- <h3>Using g.region in a shell in combination with OGR</h3>
- <!-- why not 'v.in.ogr spatial=' ?? -->
- Extracting a spatial subset of the external vector map
- <tt>soils.shp</tt> into new external vector map <tt>soils_cut.shp</tt>
- using the OGR <em>ogr2ogr</em> tool:<br>
- <div class="code"><pre>
- eval `g.region -g`
- ogr2ogr -spat $w $s $e $n soils_cut.shp soils.shp
- </pre></div>
- This requires that the location/SHAPE file projection match.
- <h3>Using g.region in a shell in combination with GDAL</h3>
- Extracting a spatial subset of the external raster map
- <tt>p016r035_7t20020524_z17_nn30.tif</tt> into new external raster
- map <tt>p016r035_7t20020524_nc_spm_wake_nn30.tif</tt> using the GDAL
- <em>gdalwarp</em> tool:<br>
- <div class="code"><pre>
- eval `g.region -g`
- gdalwarp -t_srs "`g.proj -wf`" -te $w $s $e $n \
- p016r035_7t20020524_z17_nn30.tif \
- p016r035_7t20020524_nc_spm_wake_nn30.tif
- </pre></div>
- Here the input raster map does not have to match the location
- projection since it is reprojected on the fly.
- <h2>SEE ALSO</h2>
- <em>
- <a href="g.access.html">g.access</a>,
- <a href="g.mapsets.html">g.mapsets</a>,
- <a href="g.proj.html">g.proj</a>
- <br>
- Environment variables: <a href="variables.html#internal">GRASS_REGION and WIND_OVERRIDE</a>
- </em>
- <h2>AUTHOR</h2>
- Michael Shapiro,
- U.S.Army Construction Engineering
- Research Laboratory
|