Learn R Programming

terra (version 1.7-83)

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

183,196

Version

1.7-83

License

GPL (>= 3)

Maintainer

Last Published

October 14th, 2024

Functions in terra (1.7-83)

animate

Animate a SpatRaster
all.equal

Compare two SpatRasters for equality
align

Align a SpatExtent
as.lines

Conversion to a SpatVector of lines
as.character

Create a text representation of (the skeleton of) an object
as.data.frame

SpatRaster or SpatVector to data.frame
aggregate

Aggregate raster or vector data
Arith-methods

Arithmetic
app

Apply a function to the cells of a SpatRaster
approximate

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

Conversion to a SpatVector of polygons
as.raster

Coerce to a "raster" object
boundaries

Detect boundaries (edges)
boxplot

Box plot of SpatRaster data
bestMatch

bestMatch
buffer

Create a buffer around vector geometries or raster patches
add_box

draw a box
barplot

Bar plot of a SpatRaster
clamp

Clamp values
catalyze

Factors to numeric
centroids

Centroids
clamp_ts

clamp time series data
cells

Get cell numbers
atan2

Two argument arc-tangent
classify

Classify (or reclassify) cell values
as.points

Conversion to a SpatVector of points
colors

Color table
cellSize

Area covered by each raster cell
as.list

Coerce a Spat* object to a list
click

Query by clicking on a map
contour

Contour plot
concats

Concatenate categorical rasters
convHull

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

Combine geometries
Compare-methods

Compare and logical methods
crs

Get or set a coordinate reference system
compareGeom

Compare geometries of SpatRasters
datatype

Data type of a SpatRaster or SpatVector
costDist

Cost-distance
autocorrelation

Spatial autocorrelation
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
crop

Cut out a geographic subset
diff

Lagged differences
direction

Direction
extend

Extend
ext

Create, get or set a SpatExtent
draw

Draw a polygon, line, extent, or points
erase

Erase parts of a SpatVector object
disagg

Disaggregate raster cells or vector geometries
crosstab

Cross-tabulate
depth

depth of SpatRaster layers
describe

describe
expanse

Get the expanse (area) of individual polygons or for all (summed) raster cells
flip

Flip or reverse a raster
coerce

Coercion to vector, matrix or array
tighten

tighten SpatRaster or SpatRasterDataset objects
c

Combine SpatRaster or SpatVector objects
cartogram

Cartogram
flowAccumulation

Flow accumulation
geomtype

Geometry type of a SpatVector
focalCpp

Compute focal values with an iterating C++ function
global

global statistics
focalMat

Focal weights matrix
cover

Replace values with values from another object
focalValues

Get focal values
forceCCW

force counter-clockwise polygons
image

SpatRaster image method
impose

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

Extract values for a range of layers from a SpatRaster
factors

Categorical rasters
fillHoles

Remove holes from polygons
gdal

GDAL version, supported file formats, and cache size
fillTime

Fill time gaps in a SpatRaster
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
geom

Get the geometry (coordinates) of a SpatVector
identical

Compare two SpatRasters for equality
gridDistance

Distance on a grid
deepcopy

Deep copy
interpNear

Nearest neighbor interpolation
distance

Geographic distance
densify

Add additional nodes to lines or polygons
ifel

ifelse for SpatRasters
makeTiles

Make tiles or get their extents
interpolation

Spatial interpolation
elongate

elongate lines
halo

Add halo-ed text to a plot
density

Density plot
makeVRT

Make a VRT header file
mask

Mask values in a SpatRaster or SpatVector
dots

Make a dot-density map
extract

Extract values from a SpatRaster
deprecated

deprecated methods
map.pal

color palettes for mapping
focal

Focal values
focal3D

Three-dimensional focal values
mem

Memory available and needed
graticule

Create a graticule
inset

Make an inset map
map_extent

Get the coordinates of the extent of a map
is.rotated

Check for rotation
extractAlong

extract values along lines
focalPairs

Focal function across two layers
match

Value matching for SpatRasters
mosaic

mosaic SpatRasters
is.valid

Check or fix polygon or extent validity
freq

Frequency table
na.omit

Find and remove geometries that are NA
add_grid

add a grid to a map made with terra
layerCor

Correlation and (weighted) covariance
gaps

Find gaps between polygons
not.na

is not NA
add_legend

add a custom legend
headtail

head and tail of a SpatRaster or SpatVector
plet

Plot with leaflet
plot

Make a map
merge

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

Focal regression
hist

Histogram
project

Change the coordinate reference system
quantile

Quantiles of spatial data
origin

Origin
is.lonlat

Check for longitude/latitude crs
rasterizeWin

Rasterize points with a moving window
scale

Scale values
initialize

Initialize a SpatRaster with values
rcl

Combine row, column, and layer numbers
mergeTime

merge SpatRasters by timelines to create a single timeseries
normalize.longitude

normalize vector data that crosses the dateline
inplace

Change values in-place
north

North arrow
intersect

Intersection
plotRGB

Red-Green-Blue plot of a multi-layered SpatRaster
same.crs

Compare coordinate reference systems
patches

Detect patches (clumps) of cells
is.bool

Raster value types
transpose

Transpose
plot_graticule

Plot a graticule
extremes

Get or compute the minimum and maximum cell values
is.empty

Check if a SpatExtent or SpatVector is empty
query

Query a SpatVectorProxy object
serialize

saveRDS and serialize for SpatVector and SpatRaster*
perim

Perimeter or length
spatSample

Take a regular sample
plot_extent

Plot a SpatExtent
interpIDW

Interpolate points using a moving window
selectHighest

select cells with high or low values
k_means

k_means
pairs

Pairs plot (matrix of scatterplots)
modal

modal value
lines

Add points, lines, or polygons to a map
linearUnits

Linear units of the coordinate reference system
lapp

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

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

Names of Spat* objects
split

Split
replace_values

Replace values of a SpatRaster
shift

Shift
sieve

Sieve filter
union

Union SpatVector or SpatExtent objects
predict

Spatial model predictions
princomp

SpatRaster PCA with princomp
unique

Unique values
units

units of SpatRaster or SpatRasterDataSet
update

Change values in a file
Math-methods

General mathematical methods
readwrite

Read from, or write to, file
topology

Vector topology methods
resample

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

Catchment delineation
options

Options
nearest

nearby geometries
meta

meta
rectify

Rectify a SpatRaster
metags

Set or get metadata
rep

Replicate layers
scatterplot

Scatterplot of two SpatRaster layers
prcomp

SpatRaster PCA with prcomp
xapp

Apply a function to the cells of a two SpatRasters
replace_dollar

Replace with $<-
weighted.mean

Weighted mean of layers
sapp

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

simplifyGeom geometries
panel

Map panel
vect

Create SpatVector objects
rangeFill

Fill layers with a range
persp

Perspective plot
rapp

Range-apply
pitfinder

Pit Finder in a Flow Dir SpatRaster for Watershed Extraction
rast

Create a SpatRaster
setValues

Set the values of raster cells or of geometry attributes
where

Where are the cells with the min or max values?
sharedPaths

Shared paths
svc

Create a SpatVectorCollection
rasterize

Rasterize vector data
symdif

Symmetrical difference
rasterizeGeom

Rasterize geometric properties of vector data
xyRowColCell

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

scale bar
which.lyr

Which cells are TRUE?
terrain

terrain characteristics
replace_layers

Replace layers or variables
scoff

Scale (gain) and offset
regress

Cell level regression
shade

Hill shading
rescale

rescale
sds

Create a SpatRasterDataset
sources

Data sources of a SpatRaster
writeVector

Write SpatVector data to a file
relate

Spatial relationships between geometries
spin

spin a SpatVector
trim

Trim a SpatRaster
roll

Rolling (moving) functions
sprc

Create a SpatRasterCollection
segregate

segregate
subset_double

Subset a SpatRaster or a SpatVector
tapp

Apply a function to subsets of layers of a SpatRaster
sel

Spatial selection
stretch

Stretch
terra-package

Description of the methods in the terra package
rotate

Rotate data along longitude
summarize

Summarize
summary

summary
values

Cell values and geometry attributes
subset

Subset a SpatRaster or a SpatVector
writeRaster

Write raster data to a file
xmin

Get or set single values of an extent
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
subst

replace cell values
varnames

variable and long variable names
text

Add labels to a map
time

time of SpatRaster layers
vrt

Virtual Raster Dataset
vector_layers

List or remove layers from a vector file
wrap

wrap and unwrap
vrt_tiles

filenames of VRT tiles
sort

Sort a SpatRaster or SpatVector
viewshed

Compute a viewshed
width

SpatVector geometric properties
window

Set a window
subset_dollar

Subset a SpatRaster or a SpatVector
wrapCache

SpatRaster wrap with caching options
writeCDF

Write raster data to a NetCDF file
zonal

Zonal statistics
zoom

Zoom in on a map
tmpFiles

Temporary files
voronoi

Voronoi diagram and Delaunay triangles
NAflag

Set the NA flag
SpatRaster-class

SpatRaster class
activeCat

Active category
SpatVector-class

Class "SpatVector"
add

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

Number of immediate adjacent cells flowing into each cell
RGB

Layers representing colors
SpatExtent-class

Class "SpatExtent"
add_mtext

draw a box
adjacent

Adjacent cells