Learn R Programming

terra (version 1.7-78)

Spatial Data Analysis

Description

Methods for spatial data analysis with vector (points, lines, polygons) and raster (grid) data. Methods for vector data include geometric operations such as intersect and buffer. Raster methods include local, focal, global, zonal and geometric operations. The predict and interpolate methods facilitate the use of regression type (interpolation, machine learning) models for spatial prediction, including with satellite remote sensing data. Processing of very large files is supported. See the manual and tutorials on to get started. 'terra' replaces the 'raster' package ('terra' can do more, and it is faster and easier to use).

Copy Link

Version

Install

install.packages('terra')

Monthly Downloads

125,186

Version

1.7-78

License

GPL (>= 3)

Maintainer

Last Published

May 22nd, 2024

Functions in terra (1.7-78)

SpatVector-class

Class "SpatVector"
aggregate

Aggregate raster or vector data
add

Add (in place) a SpatRaster to another SpatRaster or to a SpatRasterDataset or SpatRasterCollection
adjacent

Adjacent cells
NAflag

Set the NA flag
as.list

Coerce a Spat* object to a list
as.points

Conversion to a SpatVector of points
RGB

Layers representing colors
align

Align a SpatExtent
activeCat

Active category
boxplot

Box plot of SpatRaster data
all.equal

Compare two SpatRasters for equality
animate

Animate a SpatRaster
Arith-methods

Arithmetic
as.polygons

Conversion to a SpatVector of polygons
barplot

Bar plot of a SpatRaster
as.raster

Coerce to a "raster" object
SpatExtent-class

Class "SpatExtent"
SpatRaster-class

SpatRaster class
bestMatch

bestMatch
as.character

Create a text representation of (the skeleton of) an object
c

Combine SpatRaster or SpatVector objects
buffer

Create a buffer around vector geometries or raster patches
cartogram

Cartogram
cells

Get cell numbers
Compare-methods

Compare and logical methods
app

Apply a function to the cells of a SpatRaster
approximate

Estimate values for cell values that are NA by interpolating between layers
as.data.frame

SpatRaster or SpatVector to data.frame
crs

Get or set a coordinate reference system
as.lines

Conversion to a SpatVector of lines
classify

Classify (or reclassify) cell values
compareGeom

Compare geometries of SpatRasters
click

Query by clicking on a map
boundaries

Detect boundaries (edges)
atan2

Two argument arc-tangent
datatype

Data type of a SpatRaster or SpatVector
autocorrelation

Spatial autocorrelation
coerce

Coercion to vector, matrix or array
depth

depth of SpatRaster layers
add_box

draw a box
describe

describe
extract

Extract values from a SpatRaster
clamp

Clamp values
centroids

Centroids
distance

Geographic distance
extractAlong

extract values along lines
dots

Make a dot-density map
clamp_ts

clamp time series data
catalyze

Factors to numeric
concats

Concatenate categorical rasters
fillHoles

Remove holes from polygons
fillTime

Fill time gaps in a SpatRaster
contour

Contour plot
flip

Flip or reverse a raster
cover

Replace values with values from another object
tighten

tighten SpatRaster or SpatRasterDataset objects
focal3D

Three-dimensional focal values
cellSize

Area covered by each raster cell
focalMat

Focal weights matrix
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
convHull

Convex hull, minimal bounding rotated rectangle, and minimal bounding circle
costDist

Cost-distance
density

Density plot
focal

Focal values
deprecated

deprecated methods
halo

Add halo-ed text to a plot
diff

Lagged differences
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
erase

Erase parts of a SpatVector object
headtail

head and tail of a SpatRaster or SpatVector
expanse

Get the expanse (area) of individual polygons or for all (summed) raster cells
is.bool

Raster value types
focalReg

Focal regression
focalValues

Get focal values
colors

Color table
is.empty

Check if a SpatExtent or SpatVector is empty
combineGeoms

Combine geometries
crop

Cut out a geographic subset
focalPairs

Focal function across two layers
add_legend

add a custom legend
focalCpp

Compute focal values with an iterating C++ function
crosstab

Cross-tabulate
linearUnits

Linear units of the coordinate reference system
extremes

Get or compute the minimum and maximum cell values
deepcopy

Deep copy
interpIDW

Interpolate points using a moving window
geom

Get the geometry (coordinates) of a SpatVector
direction

Direction
modal

modal value
disagg

Disaggregate raster cells or vector geometries
add_grid

add a grid to a map made with terra
persp

Perspective plot
densify

Add additional nodes to lines or polygons
interpNear

Nearest neighbor interpolation
gridDistance

Distance on a grid
is.lonlat

Check for longitude/latitude crs
ext

Create, get or set a SpatExtent
impose

Impose the geometry of a SpatRaster to those in a SpatRasterCollection.
geomtype

Geometry type of a SpatVector
initialize

Initialize a SpatRaster with values
hist

Histogram
is.rotated

Check for rotation
meta

meta
draw

Draw a polygon, line, extent, or points
metags

Set or get metadata
elongate

elongate lines
extend

Extend
lapp

Apply a function to layers of a SpatRaster, or sub-datasets of a SpatRasterDataset
princomp

SpatRaster PCA with princomp
plet

Plot with leaflet
extractRange

Extract values for a range of layers from a SpatRaster
prcomp

SpatRaster PCA with prcomp
forceCCW

force counter-clockwise polygons
freq

Frequency table
identical

Compare two SpatRasters for equality
predict

Spatial model predictions
Math-methods

General mathematical methods
layerCor

Correlation and (weighted) covariance
gaps

Find gaps between polygons
factors

Categorical rasters
rasterizeGeom

Rasterize geometric properties of vector data
rasterizeWin

Rasterize points with a moving window
mem

Memory available and needed
gdal

GDAL version, supported file formats, and cache size
global

global statistics
inplace

Change values in-place
project

Change the coordinate reference system
lines

Add points, lines, or polygons to a map
graticule

Create a graticule
makeTiles

Make tiles or get their extents
replace_dollar

Replace with $<-
replace_layers

Replace layers or variables
merge

Merge SpatRasters, or merge a SpatVector with a data.frame
rcl

Combine row, column, and layer numbers
scatterplot

Scatterplot of two SpatRaster layers
ifel

ifelse for SpatRasters
scoff

Scale (gain) and offset
inset

Make an inset map
image

SpatRaster image method
mosaic

mosaic SpatRasters
na.omit

Find and remove geometries that are NA
interpolation

Spatial interpolation
patches

Detect patches (clumps) of cells
mergeTime

merge SpatRasters by timelines to create a single timeseries
perim

Perimeter or length
subset

Subset a SpatRaster or a SpatVector
is.valid

Check or fix polygon or extent validity
k_means

k_means
plot

Make a map
readwrite

Read from, or write to, file
relate

Spatial relationships between geometries
subset_dollar

Subset a SpatRaster or a SpatVector
intersect

Intersection
rep

Replicate layers
time

time of SpatRaster layers
mask

Mask values in a SpatRaster or SpatVector
plotRGB

Red-Green-Blue plot of a multi-layered SpatRaster
normalize.longitude

normalize vector data that crosses the dateline
match

Value matching for SpatRasters
not.na

is not NA
north

North arrow
sbar

scale bar
rotate

Rotate data along longitude
origin

Origin
scale

Scale values
makeVRT

Make a VRT header file
tmpFiles

Temporary files
same.crs

Compare coordinate reference systems
sort

Sort a SpatRaster or SpatVector
map.pal

map.pal arrow
vector_layers

List or remove layers from a vector file
selectRange

Select the values of a range of layers, as specified by cell values in another SpatRaster
serialize

saveRDS and serialize for SpatVector and SpatRaster*
names

Names of Spat* objects
plot_extent

Plot a SpatExtent
viewshed

Compute a viewshed
subst

replace cell values
quantile

Quantiles of spatial data
sources

Data sources of a SpatRaster
summarize

Summarize
terra-package

Description of the methods in the terra package
options

Options
query

Query a SpatVectorProxy object
spin

spin a SpatVector
trim

Trim a SpatRaster
union

Union SpatVector or SpatExtent objects
plot_graticule

Plot a graticule
nearest

nearby geometries
rangeFill

Fill layers with a range
rectify

Rectify a SpatRaster
rapp

Range-apply
pairs

Pairs plot (matrix of scatterplots)
replace_values

Replace values of a SpatRaster
width

SpatVector geometric properties
window

Set a window
split

Split
varnames

variable and long variable names
regress

Cell level regression
resample

Transfer values of a SpatRaster to another one with a different geometry
panel

Map panel
sel

Spatial selection
zoom

Zoom in on a map
zonal

Zonal statistics
rast

Create a SpatRaster
rasterize

Rasterize vector data
selectHighest

select cells with high or low values
writeVector

Write SpatVector data to a file
rescale

rescale
roll

Rolling (moving) functions
sds

Create a SpatRasterDataset
spatSample

Take a regular sample
setValues

Set the values of raster cells or of geometry attributes
sapp

Apply a terra function that takes only a single layer and returns a SpatRaster to all layers of a SpatRaster
shade

Hill shading
terrain

terrain characteristics
sharedPaths

Shared paths
shift

Shift
text

Add labels to a map
segregate

segregate
update

Change values in a file
vect

Create SpatVector objects
xapp

Apply a function to the cells of a two SpatRasters
vrt_tiles

filenames of VRT tiles
sprc

Create a SpatRasterCollection
sieve

Sieve filter
weighted.mean

Weighted mean of layers
stretch

Stretch
summary

summary
values

Cell values and geometry attributes
simplifyGeom

simplifyGeom geometries
wrap

wrap and unwrap
wrapCache

SpatRaster wrap with caching options
svc

Create a SpatVectorCollection
subset_double

Subset a SpatRaster or a SpatVector
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
topology

Vector topology methods
symdif

Symmetrical difference
transpose

Transpose
tapp

Apply a function to subsets of layers of a SpatRaster
where

Where are the cells with the min or max values?
which.lyr

Which cells are TRUE?
xmin

Get or set single values of an extent
xyRowColCell

Coordinates from a row, column or cell number and vice versa
unique

Unique values
units

units of SpatRaster or SpatRasterDataSet
voronoi

Voronoi diagram and Delaunay triangles
vrt

Virtual Raster Dataset
writeCDF

Write raster data to a NetCDF file
writeRaster

Write raster data to a file