
Report or change the extent, dimensions, and/or resolution of a region GRASS
Source:R/region.r
region.RdThese functions either change the extent, dimensions, and/or resolution of a GRASS "region" or report the current region's extent, dimensions, and/or resolution (see vignette("regions", package = "fasterRaster")). These functions are mostly used internally and rarely of interest to most users.
.region(): All 2D and 3D aspects of a region..regionDim(): x- and y-dimensions..regionExt(): x- and y-extent..regionRes(): x- and y-resolution.
Usage
# S4 method for class 'missing'
.region(x)
# S4 method for class 'SpatRaster'
.region(x)
# S4 method for class 'GRegion'
.region(x)
# S4 method for class 'GRaster'
.region(x, trim = NULL)
# S4 method for class 'GVector'
.region(x)
# S4 method for class 'missing'
.regionExt(x)
# S4 method for class 'numeric'
.regionExt(x, respect)
# S4 method for class 'GSpatial'
.regionExt(x, respect)
# S4 method for class 'missing'
.regionDim(x)
# S4 method for class 'numeric'
.regionDim(x, respect)
# S4 method for class 'GRegion'
.regionDim(x, respect)
# S4 method for class 'missing'
.regionRes(x)
# S4 method for class 'numeric'
.regionRes(x, respect)
# S4 method for class 'GRegion'
.regionRes(x, respect)Arguments
- x
Any of:
Missing (default): Reports the extent, resolution, and dimensions of the current region. All other arguments will be ignored. You can also use
ext(),dim(), andres()and related functions with missing arguments.A
GSpatial,GRegion,GRaster,GVectorobject: Sets the region"s extent, dimensions, and/or resolution to those of the object.A
numericvector. This will resize the region's extent, resample the region's resolution/dimensions, or both, to ensure the desired dimensions or resolution are retained: * 2 values for.regionDim(): Number of rows and columns * 4 values for.regionExt(): Westernmost and easternmost easting (longitude), and southernmost and northernmost northing (latitude) * 2 values for.regionRes(): Size of cells in the x- and y-dimensions
- trim
A
GRasterorNULL(default). If aGRaster, then the region will be trimmed to the non-NAcells in this raster.trimcan only be non-NULLifxis aGRaster. Ignored ifNULL.- respect
Character or
GRaster: Indicates what aspect(s) of the current region to retain. Different functions allow for a different aspect to be retained. Partial matching is used..regionDim():"extent"(extent unchanged, resolution may be changed) or"resolution"(resolution unchanged, extent may be changed)..regionExt():"dimensions"(dimensions unchanged, extent may be changed) or"resolution"(resolution unchanged, extent may be changed)..regionRes():"extent"(extent may be changed and/or dimensions may be changed to accommodate desired cell size) or"dimensions"(extent may be changed, dimensions unchanged). Alternatively, aGRastercan be supplied:.regionDim(): New region will have same extent and resolution..regionExt(): New region will have same dimensions and resolution..regionRes(): New region will have same extent and dimensions.
In this case, the new region"s registration will be the same as this raster, and cell resolution will be the same
Note: In most cases extent cannot be retained exactly if the resolution is changed. When resolution is changed, the actual extent will be the user-supplied extent expanded by zero to one rows or zero to one columns to accommodate an integer number of cells of the desired size. The western and northern limits of the extent will be retained, while the eastern and southern limits of the extent will be moved to accommodate an integer number of columns and rows.
Value
The value returned depends on how the function is used:
If used with no arguments,
.region()returns aGRegionobject.If used with no arguments,
.regionDim(),.regionExt(), and.regionRes()return numeric or integer vectors.If the function is used to change reshape/resample the region, it returns a
GRegionobject reflecting the region before it was changed. This allows users to revert to the original region if desired.