
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.RdThe 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
GLocationclass stores information about the GRASS "project"/"location"(seevignette("projects_mapsets", package = "fasterRaster")), and coordinate reference system. Contained by all the rest.The
GSpatialclass contains theGLocationclass and stores information about spatial objects (extent, topology) plus the name of the file representing it in GRASS (itssource). Contained byGRegion,GRaster, andGVector.The
GRegionclass contains theGSpatialclass and stores information about grids (dimensions and resolution). They do havesources, but these are not used (they're alwaysNA). Contained byGRaster. TheGRegioncorresponds to GRASS "regions", thoughGRegionobjects are not actually pointers to GRASS "region" files (seevignette("regions", package = "fasterRaster")).The
GRasterclass contains theGRegionclass and represents rasters. It stores information on number of layers, categories, min/max values, and user-friendly names. CategoricalGRasters are associated with a "levels" table for representing categorical data (e.g., wetlands, forest, etc.).The
GVectorclass contains theGSpatialclass 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
locationCharacter (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").mapsetCharacter (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").workDirCharacter (all classes): Directory in which GRASS stores files.
topologyCharacter (
GSpatialobjects, includingGRegions,GRasters, andGVectors): Valid values are2D(2-dimensional–most rasters and vectors) or3D(3-dimensional–e.g., LIDAR data). Can be obtained usingtopology().sourcesCharacter (
GRasters andGVectors): 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().namesCharacter (
GRasters only): Name of a raster or each raster layer in. Can be obtained usingnames().crsCharacter (all classes): Coordinate reference systems string (preferably in WKT2 format). Can be obtained using
crs()orst_crs().projectionCharacter: The GRASS "projection" for a
GRasterorGVector. Can be obtained using.projection().dimensionsDimensions:
GRegions andGRasters: Vector of three integers indicating number of rows, columns, and depths (for 3D objects). Can be obtained usingdim(), plusnrow(),ncol(), andndepth().GVectorss: Vector of two integers indicating number of geometries and number of fields. Can be obtained usingdim(), plusnrow()andncol().
extentNumeric vector with four values (
GSpatialobjects, includingGRegions,GRasters, andGVectors): Extent of the object listed in order from westernmost longitude, easternmost longitude, southernmost latitude, northernmost latitude. Can be obtained usingext().zextentNumeric (
GSpatialobjects, includingGRegions,GRasters, andGVectors): Bottom- and top-most extents of 3DGRasters andGVectors. Can be obtained usingzext().geometryCharacter (
GVectorss): Eitherpoints,lines, orpolygons. Can be obtained usinggeomtype().nLayersInteger (
GRasters): Number of layers ("stacked" rasters–different from number of depths of 3D rasters). Can be obtained usingnlyr().nGeometriesInteger (
GVectors): Number of features (points, lines, or polygons). Can be obtained usingnrow().datatypeGRASSCharacter (
GRasters): 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().resolutionVector of two numeric values (
GRegions, includingGRasters): Size of a raster cell in the east-west direction and in the north-south direction. Can be obtained usingres()andres3d().minVal,maxValNumeric (
GRasters): Minimum and maximum value across all cells. Can be obtained usingminmax().activeCatInteger (
GRasters): 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@activeCatis2, then the user would see "1" when printed. Can be obtained usingactiveCat().levelsList of
data.tables (GRasters): Tables for categorical rasters. If a raster is not categorical, thedata.tableisNULL, as indata.table(NULL). Can be obtained usinglevels()orcats().tabledata.table(GVectors): 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.catNameCharacter (
GVectors): Name of the column in the vector's database that contains category values (integers).