g.region(1)
π g.region π β from the GRASS GIS User's Manual, but like, explained by your bestie
okay so bestie, sit down, hydrate, because g.region(1) is genuinely one of the most important little tools in all of GRASS and I need you to understand it. π
πΈ NAME πΈ
g.region β manages the boundary definitions for the geographic region. that's it. that's the whole job. and it slays at it.
π KEYWORDS π
general, settings, computational region, extent, resolution, level1
β¨ SYNOPSIS β¨
g.region
g.region --help
g.region [-dsplectwmn3bgfauo] [region=name] [raster=name[,name,...]]
[raster_3d=name] [vector=name[,name,...]] [n=value] [s=value]
[e=value] [w=value] [t=value] [b=value] [rows=value]
[cols=value] [res=value] [res3=value] [nsres=value]
[ewres=value] [tbres=value] [zoom=name] [align=name]
[grow=value] [save=name] [--overwrite] [--help] [--verbose]
[--quiet] [--ui]
π© Flags π©
-dβ set the region from the default region. reset button, basically β¨-sβ save as default region. only possible from thePERMANENTmapset, so don't get cute with it from anywhere else π-pβ print the current region-lβ print the current region in lat/long using the current ellipsoid/datum-eβ print the current region extent-cβ print the current region map center coordinates-tβ print the current region in GMT style-wβ print the current region in WMS style-mβ print region resolution in meters (geodesic)-nβ print the convergence angle (degrees CCW). it's the difference between the projection's grid north and true north, measured at the center coordinates of the current region. lowkey the most niche flag here and I respect it-3β print also 3D settings-bβ print the maximum bounding box in lat/long on WGS84-gβ print in shell script style-fβ print in shell script style, but in one line (flat)-aβ align region to resolution (default = align to bounds, works only for 2D resolution)-uβ do not update the current region-oβ force update of the current region--overwriteβ allow output files to overwrite existing files--helpβ print usage summary--verboseβ verbose module output--quietβ quiet module output--uiβ force launching GUI dialog
π Parameters π
region=nameβ set current region from a named regionraster=name[,name,...]β set region to match raster map(s)raster_3d=nameβ set region to match 3D raster map(s) (both 2D and 3D values)vector=name[,name,...]β set region to match vector map(s)n=valueβ value for the northern edges=valueβ value for the southern edgee=valueβ value for the eastern edgew=valueβ value for the western edget=valueβ value for the top edgeb=valueβ value for the bottom edgerows=valueβ number of rows in the new regioncols=valueβ number of columns in the new regionres=valueβ 2D grid resolution (north-south and east-west)res3=valueβ 3D grid resolution (north-south, east-west and top-bottom)nsres=valueβ north-south 2D grid resolutionewres=valueβ east-west 2D grid resolutiontbres=valueβ top-bottom 3D grid resolutionzoom=nameβ shrink region until it meets non-NULL data from this raster mapalign=nameβ adjust region cells to cleanly align with this raster mapgrow=valueβ number of cells to add to each side of the current region extent. a negative number shrinks the current region extent (yes, a negative grow. iconic.)save=nameβ save current region settings in named region file
π DESCRIPTION π
so the g.region module lets you manage the settings of the current geographic region. these regional boundaries can be set by you directly, and/or set from a region definition file (which lives stored under the windows directory in your current mapset). you can create, modify, and store as many geographic region definitions as you want for any given mapset. no cap.
but here's the thing β only one of those geographic region definitions is current at any given moment, for a specified mapset. like, one at a time, bestie. so all the GRASS programs that respect the geographic region settings will use the current geographic region settings. periodt.
π DEFINITIONS π
π Region
in GRASS, a region refers to a geographic area with some defined boundaries, based on a specific map coordinate system and map projection. every region also has associated with it the specific east-west and north-south resolutions of its smallest units β those rectangular units we call "cells".
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 northings, while the east and west boundaries are called eastings. iykyk.
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 don't have to be the same, which means non-square data cells are allowed to exist. she's flexible π
typically all raster and display modules are affected by the current region settings, but not vector modules. some special modules diverge from this rule too β for example raster import modules and v.in.region. so like, exceptions exist, don't come for me.
ποΈ Default Region
each GRASS project (previously called location) has a fixed geographic region called the default geographic region (stored in the region file DEFAULT_WIND under the special mapset PERMANENT), and it defines the extent of the data base. while this gives you a starting point for defining new geographic regions, your user-defined geographic regions don't need to fall within this geographic region. the current region can be reset to the default region with the -d flag. the default region is initially set when the project is first created, and it can be reset using the -s flag.
π― Current Region
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.
πΎ Saved Regions
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 windows 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. you can also access saved region definitions stored under other mapsets in the current project, if those mapsets are included in your mapset search path, or if the '@' operator is used (region_name@mapset).
π NOTES π
after all updates have been applied, the current region's southern and western boundaries get (silently) adjusted so that the north/south distance is a multiple of the north/south resolution, and the east/west distance is a multiple of the east/west resolution. she does it quietly. no announcement. just does it. π
with the -a 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.
the -m 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.
the -p (or -g) option is recognized last. this means that all changes are applied to the region settings before printing occurs.
the -g flag prints the current region settings in shell script style. this format can be given back to g.region on its command line. this may also be used to save region settings as shell environment variables with the UNIX eval command, "eval g.region -g".
with the -u flag, the current region is not updated even if one or more options for changing region is used (res=, raster=, etc). this can be used for example to print modified region values for further use without actually modifying the current region. similarly, the -o flag forces an update of the current region file even when e.g., only printing was specified. Flag -o was added in GRASS GIS version 8 to simulate g.region behavior in prior versions when the current region file was always updated unless -u was specified.
π Additional parameter information π
zoom=name
shrink current region settings to the smallest region encompassing all non-NULL data in the named raster map layer that fall inside your current region. this way you can tightly zoom in on isolated clumps within a bigger map. so satisfying honestly π«Ά
if you also include the raster=name option on the command line, zoom=name will set the current region settings to the smallest region encompassing all non-NULL data in the named zoom map that fall inside the region stated in the cell header for the named raster map.
align=name
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 raster=name option.
β¨ EXAMPLES β¨
okay bestie this is the part where it gets fun β actual receipts, actual commands, actual output. grab a snack π
πΈ Printing extent and raster resolution in 2D and 3D
g.region -pβ prints the current region, looking like this:
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
g.region -p3β prints the current region and the 3D region (the one voxels live in), like:
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
g.region -gβ the-gflag spits the region out in script style (key=value) format:
n=4928000
s=4914000
w=590000
e=609000
nsres=20
ewres=20
rows=700
cols=950
g.region -bgβ the-bgcombo gives you that same script style (key=value) format plus the boundary box in latitude-longitude/WGS84:
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
g.region -lβ the-lflag prints the region like this:
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]
g.region -pmβ prints the current region in this format (and here the project is latitude-longitude):
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
heads up bestie: the resolution here is reported in meters, not decimal degrees. don't get caught slippin' π
π¦ Changing extent and raster resolution using values
g.region n=7360100 e=699000β resets the northing and easting for the current region, but leaves the south edge, the west edge, and the region's cell resolutions exactly where they were. no touchy. πg.region n=51:36:05N e=10:10:05E s=51:29:55N w=9:59:55E res=0:00:01β resets the northing, easting, southing, westing and resolution for the current region, and this one's in DMS latitude-longitude style. (decimal degrees and degrees with decimal minutes work too, so pick your fighter β¨)g.region -dp s=698000β sets the current region from the default region for the GRASS project, resets the south edge to698000, and then prints the result. set it, print it, slay. πg.region n=n+1000 w=w-500β plot twist: then=valuecan be a function of its own current value.n=n+valueincreases the current northing,n=n-valuedecreases it. same deal fors=value,e=value, andw=value. in this example the current region's northern boundary gets extended by1000units and the current region's western boundary gets decreased by500units.g.region n=s+1000 e=w+1000β this form lets you set region boundary values relative to each other. here, the northern boundary coordinate is set equal to1000units larger than the southern boundary's coordinate value, and the eastern boundary's coordinate value is set equal to1000units larger than the western boundary's coordinate value. the corresponding formss=n-valueandw=e-valuemay be used to set the values of the region's southern and western boundaries, relative to the northern and eastern boundary values. it's giving math bestie, and she's eating π₯
π Changing extent and raster resolution using maps
g.region raster=soilsβ makes the current region settings exactly the same as the ones in the cell header file for the raster map layersoils. copy-paste but make it spatial.g.region raster=soils zoom=soilsβ first it looks up the cell header file for the raster map layersoils, uses that as the current region setting, and then shrinks the region down to the smallest region that still encompasses all non-NULL data in the map layersoils. π«Ά
note note note: if the parameterraster=soilshad not been specified, the zoom would shrink to encompass all non-NULL data values in thesoilsmap that were located within the current region settings. different vibe, different result. iykyk.
g.region -up raster=soilsβ the-uoption suppresses the re-setting of the current region definition. super useful when you just wanna extract region info and not touch anything. in this case, the cell header file for thesoilsmap layer gets printed without changing the current region settings. look but don't touch, periodt.g.region -up zoom=soils save=soilsβ zooms into the smallest region that encompasses all non-NULLsoilsdata values, and saves the new region settings in a file to be calledsoils, stored under thewindowsdirectory in the user's current mapset. current region settings stay unbothered. π
π Changing extent and raster resolution in 3D
g.region b=0 t=3000 tbres=200 res3=100 g.region -p3β this defines 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. (and yes, that line is printed in the manual exactly as you see it β two commands, one line, iconic chaos π« )
π§ Using g.region in a shell in combination with OGR
extracting a spatial subset of the external vector map soils.shp into a new external vector map soils_cut.shp using the OGR ogr2ogr tool:
eval `g.region -g`
ogr2ogr -spat $w $s $e $n soils_cut.shp soils.shp
this requires that the project and the SHAPE file CRS' match. no mismatches allowed bestie, that's the whole rule β
π Using g.region in a shell in combination with GDAL
extracting a spatial subset of the external raster map p016r035_7t20020524_z17_nn30.tif into a new external raster map p016r035_7t20020524_nc_spm_wake_nn30.tif using the GDAL gdalwarp tool:
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
here the input raster map doesn't have to match the project's coordinate reference system, because it gets reprojected on the fly. main character energy, fr fr π
π SEE ALSO π
g.access,g.mapsets,g.proj- Environment variables:
GRASS_REGIONandWIND_OVERRIDE
πΈ AUTHOR πΈ
Michael Shapiro, U.S.Army Construction Engineering Research Laboratory
β¨ SOURCE CODE β¨
- Available at:
g.regionsource code (history) - Accessed: Saturday Jan 17 05:40:40 2026
- Main index | General index | Topics index | Keywords index | Graphical index | Full index
- Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual
and that's a wrap on g.region, bestie ππ this whole page is from GRASS 8.4.2, section g.region(1), and that Saturday Jan 17 05:40:40 2026 access date β so if you're reading this way later, go peep the fresh docs. now go set a region and make it make sense, you got this π«Άβ¨
π¦ where this page comes from
- fedora 44: grass 8.4.2-4.fc44 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms