Skip to contents

Where to start

faster()
Set or get options shared across fasterRaster functions
fast(<character>) fast(<SpatRaster>) fast(<SpatVector>) fast(<sf>) fast(<missing>) fast(<numeric>) fast(<data.frame>) fast(<data.table>) fast(<matrix>)
Create a GRaster or GVector
rast(<GRaster>)
Convert a GRaster to a SpatRaster
vect(<GVector>) st_as_sf(<GVector>)
Convert a GVector to a SpatVector or sf vector
writeRaster(<GRaster>,<character>) writeRaster(<missing>,<missing>)
Save a GRaster to disk
writeVector(<GVector>,<character>) writeVector(<missing>,<missing>)
Save a GVector to disk
addons()
Test if addons directory exists and if an addon is installed

GRaster properties

crs(<missing>) crs(<GLocation>) st_crs() coordRef(<missing>) coordRef(<GRaster>) coordRef(<GVector>)
Coordinate reference system of a GRaster or GVector
datatype(<GRaster>) datatype(<GVector>)
Get the datatype of a GRaster or of GVector columns
dim(<GRegion>) dim3d(<missing>) dim3d(<GRegion>) nrow(<missing>) nrow(<GRegion>) ncol(<missing>) ncol(<GRegion>) ndepth(<missing>) ndepth(<GRegion>) ncell(<missing>) ncell(<GRegion>) ncell3d(<missing>) ncell3d(<GRegion>) dim(<GVector>) nrow(<GVector>) ncol(<GVector>) nlyr(<missing>) nlyr(<GRaster>)
Number of rows, columns, depths, cells, and layers
ext(<missing>) ext(<GSpatial>) zext(<missing>) zext(<GSpatial>) W(<missing>) W(<GSpatial>) E(<missing>) E(<GSpatial>) N(<missing>) N(<GSpatial>) S(<missing>) S(<GSpatial>) top(<missing>) top(<GSpatial>) bottom(<GSpatial>)
Spatial bounds of a GRaster or GVector
freq(<GRaster>)
Frequencies of cell values in a raster
is.2d(<GSpatial>) is.3d(<GSpatial>)
Test if a GRaster or GVector is 2- or 3-dimensional
is.int(<GRaster>) is.cell(<GRaster>) is.float(<GRaster>) is.doub(<GRaster>) is.factor(<GRaster>)
Data type of a raster
is.lonlat(<character>) is.lonlat(<GLocation>) is.lonlat(<sf>)
Test if a coordinate reference system is unprojected
levels(<GRaster>) cats(<GRaster>) categories(<GRaster>) `levels<-`(<GRaster>,<data.frame>) `levels<-`(<GRaster>,<data.table>) `levels<-`(<GRaster>,<GRaster>) `levels<-`(<GRaster>,<list>)
Set and get categories for categorical rasters
minmax(<GRaster>)
Minimum and maximum values or categories of a GRaster
names(<GRaster>) `names<-`(<GRaster>) names(<GVector>) `names<-`(<GVector>)
Name(s) of a GRaster or columns of a GVector's data table
nacell(<GRaster>) nonnacell(<GRaster>)
Number of NA or non-NA cells in a raster
nlevels(<GRaster>)
Number of categories in a categorical raster
res(<missing>) res(<GRegion>) xres(<missing>) xres(<GRegion>) yres(<missing>) yres(<GRegion>) zres(<missing>) zres(<GRegion>) res3d(<missing>) res3d(<GRegion>)
Spatial resolution
sources(<GRaster>) sources(<GVector>) sources(<character>)
Name of a raster or vector in a GRASS session
topology(<GSpatial>)
Topology (2- or 3-dimensions) of a GRaster or GVector

Math, comparison, and logic

Math layer-by-layer on GRasters

Math across GRaster layers

Subsetting and replacing GRasters

`$`(<GRaster>) `$`(<GVector>)
Subset a GRaster layer, or return values from a column of a GVector's table
`$<-`(<GRaster>) `$<-`(<GVector>)
Replace a raster layer or a column from a vector's data table
`[`(<GVector>,<ANY>,<ANY>) `[`(<GRaster>,<GRaster>,<ANY>)
Subset geometries of a GVector
`[<-`(<GRaster>,<missing>,<ANY>) `[<-`(<GRaster>,<GRaster>,<ANY>)
Replace values of a GRaster
`[[<-`(<GRaster>,<ANY>)
Replace layers of a GRaster
`add<-`(<GRaster>,<GRaster>)
"Stack" a GRaster
subset(<GRaster>) subset(<GVector>)
Subset layers from a GRaster, or specific rows from a GVector

Operations on GRasters

match(<GRaster>) `%in%`(<GRaster>) `%notin%`(<GRaster>)
Find which cells of a GRaster match certain values
as.int(<GRaster>) as.float(<GRaster>) as.doub(<GRaster>)
Coerce raster to integer, float, or double precision
as.lines(<GRaster>)
Convert a raster to a lines vector
as.points(<GRaster>) as.points(<GVector>)
Convert a GRaster, or lines or polygons GVector to a points vector
as.polygons(<GRaster>)
Convert a raster to a polygons vector
aggregate(<GRaster>) aggregate(<GVector>)
Aggregate raster cells into larger cells or combine geometries of a vector
bioclims(<GRaster>) bioclims(<SpatRaster>)
BIOCLIM rasters
buffer(<GRaster>) buffer(<GVector>) st_buffer(<GVector>)
Increase/decrease the size of a vector or around non-NA cells of a raster
app(<GRaster>) appFuns() appCheck(<GRaster>,<character>)
Apply a function to a set of rasters
c(<GRaster>)
"Stack" GRasters
cellSize(<GRaster>)
Area of GRaster cells
classify(<GRaster>)
Classify GRaster cell values
clump(<GRaster>)
Group adjacent cells with similar values
combineLevels(<GRaster>) combineLevels(<list>)
Combine levels table from multiple categorical GRasters
concats(<GRaster>)
Combine values/categories of multiple GRasters into a single GRaster
crop(<GRaster>) crop(<GVector>)
Remove parts of a GRaster or GVector
denoise(<GRaster>) noise(<GRaster>)
Remove or retain "noise" in a raster using PCA
distance(<GRaster>,<missing>) distance(<GRaster>,<GVector>) distance(<GVector>,<GVector>) distance(<GVector>,<missing>)
Geographic distance
extend(<GRaster>,<numeric>) extend(<GRaster>,<SpatRaster>) extend(<GRaster>,<SpatVector>) extend(<GRaster>,<SpatExtent>) extend(<GRaster>,<sf>) extend(<GRaster>,<GSpatial>)
Add rows and columns around a writeRaster
extract(<GRaster>,<GVector>) extract(<GRaster>,<data.frame>) extract(<GRaster>,<data.table>) extract(<GRaster>,<matrix>) extract(<GRaster>,<numeric>) extract(<GVector>,<GVector>) extract(<GVector>,<data.frame>) extract(<GVector>,<data.table>) extract(<GVector>,<matrix>) extract(<GVector>,<numeric>)
Extract values from a GRaster at locations in a points GVector
fillNAs(<GRaster>)
Fill NA cells in a raster using interpolation
focal(<GRaster>)
Calculate cell values based on values of nearby cells
fragmentation(<SpatRaster>) fragmentation(<GRaster>)
Landscape fragmentation class following Riitters et al. (2020)
global(<GRaster>) global(<missing>)
Summary statistics for GRasters
hist(<GRaster>)
Plot a histogram of raster values
interpIDW(<GVector>,<GRaster>)
Interpolate values at points to a GRaster using inverse-distance weighting
kernel(<GVector>)
Kernel density estimator of points
layerCor(<GRaster>)
Correlation between GRasters
mask(<GRaster>,<GRaster>) mask(<GRaster>,<GVector>)
Mask values in a raster
maskNA(<GRaster>)
Mask all non-NA cells or all NA cells
merge(<GRaster>,<GRaster>)
Combine two or more rasters with different extents and fill in NAs
names(<GRaster>) `names<-`(<GRaster>) names(<GVector>) `names<-`(<GVector>)
Name(s) of a GRaster or columns of a GVector's data table
pairs(<GRaster>)
Scatterplot of values in each GRaster layer against the others
pcs()
Retrieve a principal components model from a PCA GRaster
plot(<GRaster>,<missing>) plot(<GVector>,<missing>)
Display a raster or vector
plotRGB(<GRaster>)
Create red-green-blue plot from a raster with RGB layers
princomp(<GRaster>)
Apply a principal component analysis (PCA) to layers of a GRaster
project(<GRaster>) project(<GVector>)
Change the coordinate reference system of a GRaster or GVector
predict(<GRaster>)
Make predictions from a linear or generalized linear model to a GRaster
regress(<GRaster>,<missing>)
Regression intercept, slope, r2, and t-value across each set of cells
resample(<GRaster>,<GRaster>) resample(<GRaster>,<numeric>)
Change the cell size of a GRaster
reorient(<GRaster>) reorient(<numeric>)
Convert degrees between 'north-orientation' and 'east orientation'
sampleRast(<GRaster>)
Randomly sample cells from a GRaster
segregate(<GRaster>)
Create one GRaster layer per unique value in a GRaster
stretch(<GRaster>)
Rescale values in a GRaster
scale(<GRaster>) scalepop(<GRaster>) unscale(<GRaster>)
Center and scale a GRaster, or the opposite
selectRange(<GRaster>)
Select values from rasters in a stack based on values in another raster
spatSample(<GRaster>) spatSample(<GVector>)
Sample random points from a GRaster or GVector
subst(<GRaster>)
Replace a specific value(s) in a GRaster
thinLines(<GRaster>)
Reduce linear features on a raster so linear features are 1 cell wide
tiles(<GRaster>)
Divide a GRaster into spatially exclusive subsets
trim(<GRaster>)
Remove rows and columns from a raster that are all NA
zonal(<GRaster>,<ANY>)
Statistics on cells of a GRaster stratified by cells of another raster
zonalGeog(<GRaster>)
Geographic statistics for sets of cells with the same values

Creating GRasters de novo

fractalRast(<GRaster>)
Create fractal raster
init(<GRaster>)
GRaster with values equal to row, column, coordinate, regular, or "chess"
longlat(<GRaster>)
Create longitude/latitude rasters
rnormRast(<GRaster>)
Create a raster with random values drawn from a normal distribution
rSpatialDepRast(<GRaster>)
Create a random raster with or without spatial dependence
runifRast(<GRaster>)
Create a raster with random values drawn from a uniform distribution
sineRast(<GRaster>)
Sine wave rasters

Terrain and hydrology

as.contour(<GRaster>)
Contour lines from a "GRaster"
flow(<GRaster>)
Identify watershed basins and direction and accumulation of flow
flowPath(<GRaster>)
Path of water flow across a landscape
geomorphons(<GRaster>)
Identify terrain feature types
hillshade(<GRaster>)
Hillshading
horizonHeight(<GRaster>)
Horizon height
sun()
Solar radiance and irradiance
ruggedness(<GRaster>)
Terrain ruggedness index
streams(<GRaster>)
Create stream network
terrain(<GRaster>)
Slope, aspect, curvature, and partial slopes
wetness(<GRaster>)
Topographic wetness index

Categorical GRasters

match(<GRaster>) `%in%`(<GRaster>) `%notin%`(<GRaster>)
Find which cells of a GRaster match certain values
activeCat(<GRaster>) activeCats(<GRaster>) `activeCat<-`(<GRaster>)
Get or set the column with category labels in a categorical raster
addCats(<GRaster>) `addCats<-`(<GRaster>)
Add rows or columns to the "levels" table of a categorical raster
levels(<GRaster>) cats(<GRaster>) categories(<GRaster>) `levels<-`(<GRaster>,<data.frame>) `levels<-`(<GRaster>,<data.table>) `levels<-`(<GRaster>,<GRaster>) `levels<-`(<GRaster>,<list>)
Set and get categories for categorical rasters
catNames(<GRaster>) catNames(<SpatRaster>)
Names of columns of the levels table of a categorical raster
combineLevels(<GRaster>) combineLevels(<list>)
Combine levels table from multiple categorical GRasters
complete.cases(<GRaster>) complete.cases(<GVector>) missing.cases(<GRaster>) missing.cases(<GVector>)
Rows of a GRaster or GVector's table that have no NAs or that have NAs
concats(<GRaster>)
Combine values/categories of multiple GRasters into a single GRaster
droplevels(<GRaster>)
Remove rows from the "levels" table of a categorical raster
freq(<GRaster>)
Frequencies of cell values in a raster
is.int(<GRaster>) is.cell(<GRaster>) is.float(<GRaster>) is.doub(<GRaster>) is.factor(<GRaster>)
Data type of a raster
minmax(<GRaster>)
Minimum and maximum values or categories of a GRaster
missingCats(<GRaster>)
Values in a categorical raster with no assigned category
nlevels(<GRaster>)
Number of categories in a categorical raster
segregate(<GRaster>)
Create one GRaster layer per unique value in a GRaster
subst(<GRaster>)
Replace a specific value(s) in a GRaster
zonalGeog(<GRaster>)
Geographic statistics for sets of cells with the same values

Remote sensing GRasters

compositeRGB(<GRaster>)
Combine red, green, and blue color bands to make a composite GRaster
plotRGB(<GRaster>)
Create red-green-blue plot from a raster with RGB layers
vegIndex(<GRaster>)
Vegetation indices from surface reflectance
bioclims(<GRaster>) bioclims(<SpatRaster>)
BIOCLIM rasters
fragmentation(<SpatRaster>) fragmentation(<GRaster>)
Landscape fragmentation class following Riitters et al. (2020)

GVectors Properties

ext(<missing>) ext(<GSpatial>) zext(<missing>) zext(<GSpatial>) W(<missing>) W(<GSpatial>) E(<missing>) E(<GSpatial>) N(<missing>) N(<GSpatial>) S(<missing>) S(<GSpatial>) top(<missing>) top(<GSpatial>) bottom(<GSpatial>)
Spatial bounds of a GRaster or GVector
crs(<missing>) crs(<GLocation>) st_crs() coordRef(<missing>) coordRef(<GRaster>) coordRef(<GVector>)
Coordinate reference system of a GRaster or GVector
datatype(<GRaster>) datatype(<GVector>)
Get the datatype of a GRaster or of GVector columns
dim(<GRegion>) dim3d(<missing>) dim3d(<GRegion>) nrow(<missing>) nrow(<GRegion>) ncol(<missing>) ncol(<GRegion>) ndepth(<missing>) ndepth(<GRegion>) ncell(<missing>) ncell(<GRegion>) ncell3d(<missing>) ncell3d(<GRegion>) dim(<GVector>) nrow(<GVector>) ncol(<GVector>) nlyr(<missing>) nlyr(<GRaster>)
Number of rows, columns, depths, cells, and layers
expanse(<GVector>)
Area of polygons or length of lines
geomtype(<GVector>) is.points(<GVector>) is.lines(<GVector>) is.polygons(<GVector>)
Geometry of a GVector (points, lines, or polygons)
is.2d(<GSpatial>) is.3d(<GSpatial>)
Test if a GRaster or GVector is 2- or 3-dimensional
is.lonlat(<character>) is.lonlat(<GLocation>) is.lonlat(<sf>)
Test if a coordinate reference system is unprojected
names(<GRaster>) `names<-`(<GRaster>) names(<GVector>) `names<-`(<GVector>)
Name(s) of a GRaster or columns of a GVector's data table
ngeom(<GVector>) nsubgeom(<GVector>)
Number of geometries and subgeometries in a vector
sources(<GRaster>) sources(<GVector>) sources(<character>)
Name of a raster or vector in a GRASS session
topology(<GSpatial>)
Topology (2- or 3-dimensions) of a GRaster or GVector

Subsetting and assignment of GVectors

`$`(<GRaster>) `$`(<GVector>)
Subset a GRaster layer, or return values from a column of a GVector's table
`$<-`(<GRaster>) `$<-`(<GVector>)
Replace a raster layer or a column from a vector's data table
`[`(<GVector>,<ANY>,<ANY>) `[`(<GRaster>,<GRaster>,<ANY>)
Subset geometries of a GVector
`[[`(<GRaster>,<ANY>,<ANY>) `[[`(<GVector>,<ANY>,<ANY>)
Subset layers from a GRaster, or specific columns from a GVector
`addTable<-`(<GVector>,<data.frame>) `addTable<-`(<GVector>,<data.table>) `addTable<-`(<GVector>,<matrix>) dropTable(<GVector>)
Attach or detach GVector's data table
subset(<GRaster>) subset(<GVector>)
Subset layers from a GRaster, or specific rows from a GVector

Operations on GVectors

aggregate(<GRaster>) aggregate(<GVector>)
Aggregate raster cells into larger cells or combine geometries of a vector
as.data.frame(<GVector>) as.data.table(<GVector>)
Convert GVector to a data frame
as.points(<GRaster>) as.points(<GVector>)
Convert a GRaster, or lines or polygons GVector to a points vector
buffer(<GRaster>) buffer(<GVector>) st_buffer(<GVector>)
Increase/decrease the size of a vector or around non-NA cells of a raster
centroids(<GVector>)
Centroid(s) of a vector
clusterPoints(<GVector>)
Identify clusters of points
colbind(<GVector>)
Add columns to the data table of a GVector
complete.cases(<GRaster>) complete.cases(<GVector>) missing.cases(<GRaster>) missing.cases(<GVector>)
Rows of a GRaster or GVector's table that have no NAs or that have NAs
connectors(<GVector>,<GVector>)
Create lines connecting nearest features of two GVectors
convHull(<GVector>)
Minimum convex hull around a spatial vector
crds(<GRaster>) crds(<GVector>) st_coordinates()
Coordinates of a vector"s features or a raster"s cell centers
crop(<GRaster>) crop(<GVector>)
Remove parts of a GRaster or GVector
delaunay(<GVector>)
Delaunay triangulation for points
disagg(<GVector>)
Coerce as multipart GVector to a singlepart GVector
distance(<GRaster>,<missing>) distance(<GRaster>,<GVector>) distance(<GVector>,<GVector>) distance(<GVector>,<missing>)
Geographic distance
`addTable<-`(<GVector>,<data.frame>) `addTable<-`(<GVector>,<data.table>) `addTable<-`(<GVector>,<matrix>) dropTable(<GVector>)
Attach or detach GVector's data table
erase(<GVector>,<GVector>)
Select parts of a polygon GVector erase shared by another polygon GVector
expanse(<GVector>)
Area of polygons or length of lines
extract(<GRaster>,<GVector>) extract(<GRaster>,<data.frame>) extract(<GRaster>,<data.table>) extract(<GRaster>,<matrix>) extract(<GRaster>,<numeric>) extract(<GVector>,<GVector>) extract(<GVector>,<data.frame>) extract(<GVector>,<data.table>) extract(<GVector>,<matrix>) extract(<GVector>,<numeric>)
Extract values from a GRaster at locations in a points GVector
grid(<GRaster>) grid(<GVector>)
Create a grid GVector
head(<GVector>) tail(<GVector>)
Return first or last part of the data frame of a GVector
hexagons(<GRaster>) hexagons(<GVector>)
Create a hexagonal grid
interpIDW(<GVector>,<GRaster>)
Interpolate values at points to a GRaster using inverse-distance weighting
interpSplines(<GVector>,<GRaster>)
Interpolate values at points to a GRaster using splines
intersect(<GVector>,<GVector>)
Intersection of two GVectors
kernel(<GVector>)
Kernel density estimator of points
names(<GRaster>) `names<-`(<GRaster>) names(<GVector>) `names<-`(<GVector>)
Name(s) of a GRaster or columns of a GVector's data table
project(<GRaster>) project(<GVector>)
Change the coordinate reference system of a GRaster or GVector
rasterize(<GVector>,<GRaster>)
Convert a GVector to a GRaster
rbind(<GVector>)
Combine one or more GVectors
simplifyGeom(<GVector>)
Simplify the geometry of a vector
smoothGeom(<GVector>)
Smooth the geometry of a vector
vect(<GVector>) st_as_sf(<GVector>)
Convert a GVector to a SpatVector or sf vector
thinPoints(<GVector>,<GRaster>)
Reduce number of points in same raster cell
union(<GVector>,<GVector>)
Combine two GVectors
voronoi(<GVector>)
Voronoi tessellation
xor(<GVector>,<GVector>)
Select parts of polygons not shared between two GVectors

Creating GVectors de novo

rvoronoi(<GRaster>) rvoronoi(<GVector>)
Create a randomly-positioned tesselation

Fixing GVector issues

Converting between data types

as.contour(<GRaster>)
Contour lines from a "GRaster"
as.int(<GRaster>) as.float(<GRaster>) as.doub(<GRaster>)
Coerce raster to integer, float, or double precision
as.data.frame(<GVector>) as.data.table(<GVector>)
Convert GVector to a data frame
as.lines(<GRaster>)
Convert a raster to a lines vector
as.points(<GRaster>) as.points(<GVector>)
Convert a GRaster, or lines or polygons GVector to a points vector
as.polygons(<GRaster>)
Convert a raster to a polygons vector
levels(<GRaster>) cats(<GRaster>) categories(<GRaster>) `levels<-`(<GRaster>,<data.frame>) `levels<-`(<GRaster>,<data.table>) `levels<-`(<GRaster>,<GRaster>) `levels<-`(<GRaster>,<list>)
Set and get categories for categorical rasters
fast(<character>) fast(<SpatRaster>) fast(<SpatVector>) fast(<sf>) fast(<missing>) fast(<numeric>) fast(<data.frame>) fast(<data.table>) fast(<matrix>)
Create a GRaster or GVector
rast(<GRaster>)
Convert a GRaster to a SpatRaster
rasterize(<GVector>,<GRaster>)
Convert a GVector to a GRaster
vect(<GVector>) st_as_sf(<GVector>)
Convert a GVector to a SpatVector or sf vector

General functions

compareGeom(<GRaster>,<GRaster>) compareGeom(<GVector>,<GVector>) compareGeom(<GRaster>,<GVector>) compareGeom(<GVector>,<GRaster>)
Determine if GRasters and/or GVectors are geographically comparable
dropRows(<data.table>) dropRows(<data.frame>) dropRows(<matrix>)
Remove rows in a data.table, data.frame, or matrix.
grassGUI(<missing>)
Start the GRASS GUI (potentially dangerous!)
grassHelp()
Open the help page for a GRASS module
grassInfo()
GRASS citation, version, and copyright information
grassStarted()
Has "GRASS" been started or not?
mow()
Remove rasters and vectors from the GRASS cache
replaceNAs(<data.frame>) replaceNAs(<matrix>) replaceNAs(<data.table>) replaceNAs(<numeric>) replaceNAs(<integer>) replaceNAs(<logical>) replaceNAs(<character>)
Replace NAs in a data.table or data.frame column, or in a vector
seqToSQL()
Format a numeric series into an SQL value call
update(<GRaster>) update(<GVector>)
Refresh metadata in a GRaster or GVector

Example data

appFunsTable
Functions that can be used in app()
fastData()
Get one of the example rasters or spatial vectors
madChelsa
Rasters of bioclimatic variables for an eastern portion of Madagascar
madCoast
Shapefile of a portion of the coastline of Madagascar
madCoast4
Spatial vector of a portion of the coastline of Madagascar
madCoast4
Spatial vector of a portion of the coastline of Madagascar
madCover
Raster of land cover for an eastern portion of Madagascar
madCoverCats
Table of land cover classes for an eastern portion of Madagascar
madDypsis
Spatial points vector of records of Dypsis in eastern Madagascar
madElev
Elevation raster for an eastern portion of Madagascar
madForest2000
Forest cover in year 2000 for a portion of Madagascar
madForest2014
Forest cover in year 2014 for a portion of Madagascar
madLANDSAT
Rasters of surface reflectance for an eastern portion of Madagascar
madPpt
Rasters of average monthly precipitation for an eastern portion of Madagascar
madTmax
Rasters of average monthly maximum temperature for an eastern portion of Madagascar
madTmin
Rasters of average monthly minimum temperature for an eastern portion of Madagascar
madRivers
Major rivers in a selected portion of Madagascar
vegIndices
Table of vegetation indices that can be calculated from remote sensing surface reflectance data using vegIndex(). A near-comprehensive table of indices can be found on the Index Database: A Database for Remote Sensing Indices.

Classes

GLocation-class GLocation GSpatial-class GSpatial GRegion-class GRegion GRaster-class GRaster GVector-class GVector
Classes for fasterRaster sessions, regions, rasters, and vectors