Classes for fasterRaster sessions, regions, rasters, and vectors
Source:R/00a_GLocation_class.r
, R/00b_GSpatial_class.r
, R/00c_GRegion_class.r
, and 2 more
GLocation.Rd
The G
-suite of S4 classes contain pointers to GRASS objects or metadata about the current GRASS session. Most users will manipulate objects using these classes, but do not need to know the details.
The
GLocation
class stores information about the GRASS "project"/"location"(seevignette("projects_mapsets", package = "fasterRaster")
), and coordinate reference system. Contained by all the rest.The
GSpatial
class contains theGLocation
class and stores information about spatial objects (extent, topology) plus the name of the file representing it in GRASS (itssource
). Contained byGRegion
,GRaster
, andGVector
.The
GRegion
class contains theGSpatial
class and stores information about grids (dimensions and resolution). They do havesources
, but these are not used (they're alwaysNA
). Contained byGRaster
. TheGRegion
corresponds to GRASS "regions", thoughGRegion
objects are not actually pointers to GRASS "region" files (seevignette("regions", package = "fasterRaster")
).The
GRaster
class contains theGRegion
class and represents rasters. It stores information on number of layers, categories, min/max values, and user-friendly names. CategoricalGRaster
s are associated with a "levels" table for representing categorical data (e.g., wetlands, forest, etc.).The
GVector
class contains theGSpatial
class and represents spatial vectors. It may or may not have an associateddata.table
(i.e., adata.frame
), which contains metadata about each geometry in the vector.
Slots
location
Character (all classes): The GRASS "project"/"location" of the object. The default value is
default
. Can be obtained using the hidden function.location()
. Seevignette("projects_mapsets", package = "fasterRaster")
.mapset
Character (all classes): The GRASS "mapset". Default value is
PERMANENT
. Typically hidden to users. Can be obtained using the hidden function.mapset()
. Seevignette("projects_mapsets", package = "fasterRaster")
.workDir
Character (all classes): Directory in which GRASS stores files.
topology
Character (
GSpatial
objects, includingGRegion
s,GRaster
s, andGVector
s): Valid values are2D
(2-dimensional–most rasters and vectors) or3D
(3-dimensional–e.g., LIDAR data). Can be obtained usingtopology()
.sources
Character (
GRaster
s andGVector
s): Name of the object in GRASS. These are typically made on-the-fly and provide the pointer to the object from R to GRASS. Changing them manually will break the connection. Can be obtained usingsources()
.names
Character (
GRaster
s only): Name of a raster or each raster layer in. Can be obtained usingnames()
.crs
Character (all classes): Coordinate reference systems string (preferably in WKT2 format). Can be obtained using
crs()
orst_crs()
.projection
Character: The GRASS "projection" for a
GRaster
orGVector
. Can be obtained using.projection()
.dimensions
Dimensions:
GRegion
s andGRaster
s: Vector of three integers indicating number of rows, columns, and depths (for 3D objects). Can be obtained usingdim()
, plusnrow()
,ncol()
, andndepth()
.GVectors
s: Vector of two integers indicating number of geometries and number of fields. Can be obtained usingdim()
, plusnrow()
andncol()
.
extent
Numeric vector with four values (
GSpatial
objects, includingGRegion
s,GRaster
s, andGVector
s): Extent of the object listed in order from westernmost longitude, easternmost longitude, southernmost latitude, northernmost latitude. Can be obtained usingext()
.zextent
Numeric (
GSpatial
objects, includingGRegion
s,GRaster
s, andGVector
s): Bottom- and top-most extents of 3DGRaster
s andGVector
s. Can be obtained usingzext()
.geometry
Character (
GVectors
s): Eitherpoints
,lines
, orpolygons
. Can be obtained usinggeomtype()
.nLayers
Integer (
GRaster
s): Number of layers ("stacked" rasters–different from number of depths of 3D rasters). Can be obtained usingnlyr()
.nGeometries
Integer (
GVector
s): Number of features (points, lines, or polygons). Can be obtained usingnrow()
.datatypeGRASS
Character (
GRaster
s): Type of data stored in a raster, as interpreted byGRASS
. This is eitherCELL
(integers),FCELL
(floating-point values), orDCELL
(double-values). Can be obtained usingdatatype()
.resolution
Vector of two numeric values (
GRegion
s, includingGRaster
s): Size of a raster cell in the east-west direction and in the north-south direction. Can be obtained usingres()
andres3d()
.minVal,maxVal
Numeric (
GRaster
s): Minimum and maximum value across all cells. Can be obtained usingminmax()
.activeCat
Integer (
GRaster
s): Column index of the category labels. Must be >0. Note that from the user's standpoint, 1 is subtracted from this number. So a value if@activeCat
is2
, then the user would see "1" when printed. Can be obtained usingactiveCat()
.levels
List of
data.table
s (GRaster
s): Tables for categorical rasters. If a raster is not categorical, thedata.table
isNULL
, as indata.table(NULL)
. Can be obtained usinglevels()
orcats()
.table
data.table
(GVector
s): Table with metadata, one row per geometry (point, line, or plane). If no table is associated with the vector, this must bedata.table(NULL)
. The column with the category value is given in@catName
.catName
Character (
GVector
s): Name of the column in the vector's database that contains category values (integers).