Learn R Programming

⚠️There's a newer version (1.8-54) of this package.Take me there.

terra (version 1.6-41)

Spatial Data Analysis

Description

Methods for spatial data analysis with vector (points, lines, polygons) and raster (grid) data. Methods for vector data include standard operations such as intersect and buffer. Raster methods include global, local, zonal, and focal computations. 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' is a replacement for the 'raster' package ('terra' can do more, and it is faster and easier to use).

Copy Link

Version

Install

install.packages('terra')

Monthly Downloads

185,852

Version

1.6-41

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

November 18th, 2022

Functions in terra (1.6-41)

NAflag

Set the NA flag
align

Align a SpatExtent
aggregate

Aggregate raster or vector data
SpatExtent-class

Class "SpatExtent"
add

Add (in place) a SpatRaster to another SpatRaster object
adjacent

Adjacent cells
activeCat

Active category
SpatVector-class

Class "SpatVector"
RGB

Layers representing colors
SpatRaster-class

SpatRaster class
as.raster

Coerce to a "raster" object
all.equal

Compare two SpatRasters for equality
animate

Animate a SpatRaster
approximate

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

SpatRaster or SpatVector to data.frame
app

Apply a function to the cells of a SpatRaster
as.list

SpatRaster* or SpatVector to list
as.character

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

Conversion to a SpatVector, or to another SpatVector type
boxplot

Box plot of SpatRaster data
Arith-methods

Arithmetic
atan2

Two argument arc-tangent
c

Combine SpatRaster or SpatVector objects
autocorrelation

Spatial autocorrelation
barplot

Bar plot of a SpatRaster
cartogram

Cartogram
tighten

tighten SpatRaster or SpatRasterDataset objects
colors

Color table
cellSize

Area covered by each raster cell
catalyze

Factors to numeric
coerce

Coercion of a SpatRaster to a vector, matrix or array
buffer

Create a buffer around vector geometries or raster patches
click

Query by clicking on a map
clamp

Clamp values
boundaries

Detect boundaries (edges)
combineGeoms

Combine geometries
cover

Replace values with values from another object
crop

Cut out a geographic subset
Compare-methods

Compare and logical methods
classify

Classify (or reclassify) cell values
direction

Direction
cells

Get cell numbers
contour

Contour plot
centroids

Centroids
convHull

Convex hull and minimal rotated rectangle
disagg

Disaggregate raster cells or vector geometries
crosstab

Cross-tabulate
describe

describe
crs

Get or set a coordinate reference system
distance

Geographic distance
deprecated

deprecated methods
dots

Make a dot-density map
density

Density plot
draw

Draw a polygon, line, extent, or points
erase

Erase parts of a SpatVector object
focalCpp

Compute focal values with an iterating C++ function
expanse

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

depth of SpatRaster layers
fillTime

Fill time gaps in a SpatRaster
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
compareGeom

Compare geometries of SpatRasters
costDist

Cost distance
concats

Concatenate categorical rasters
fillHoles

Remove holes from polygons
diff

Lagged differences
head and tail

Show the head or tail of a Spat* object
extract

Extract values from a SpatRaster
focalMat

Focal weights matrix
geomtype

Geometry type of a SpatVector
flip

Flip or reverse a raster
deepcopy

Deep copy
elongate

elongate lines
focal3D

Three-dimensional focal values
focal

Focal values
densify

Add additional nodes to lines or polygons
focalReg

Focal regression
factors

Categorical rasters
gdal

GDAL version, supported file formats, and cache size
focalCor

Focal function across two layers
focalValues

Get focal values
freq

Frequency table
geom

Get the geometry (coordinates) of a SpatVector
global

global statistics
layerCor

Correlation and (weighted) covariance
gaps

Find gaps between polygons
hist

Histogram
interpIDW

Interpolate points using a moving window
initialize

Initialize a SpatRaster with values
impose

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

Linear units of the coordinate reference system
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
ext

Create, get or set a SpatExtent
inplace

Change values in-place
interpNear

Nearest neighbor interpolation
inset

Make an inset map
mem

Memory available and needed
extend

Extend
lines

Add SpatVector data to a map
rast

Create a SpatRaster
pairs

Pairs plot (matrix of scatterplots)
graticule

Create a graticule
valid

Check or fix polygon validity
lapp

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

Make a VRT header file
makeTiles

Make tiles
nearest

nearby geometries
match

Value matching for SpatRasters
ifel

ifelse for SpatRasters
gridDistance

Distance on a grid
mergeTime

merge SpatRasters by timelines to create a single timeseries
modal

modal value
origin

Origin
image

SpatRaster image method
Spatial interpolation

Spatial interpolation
intersect

Intersection
is.bool

Raster value types
mosaic

mosaic SpatRasters
is.lonlat

Check for longitude/latitude crs
persp

Perspective plot
plet

Plot with leaflet
mask

Mask values in a SpatRaster or SpatVector
na.omit

na.omit for SpatVector
rapp

Range-apply
segregate

segregate
names

Names of Spat* objects
plot_extent

Plot a SpatExtent
merge

Merge SpatRasters, or merge a SpatVector with a data.frame
Math-methods

General mathematical methods
plot

Make a map
sort

Sort a SpatRaster
north

North arrow
not.na

is not NA
read and write

Read from, or write to, file
rectify

Rectify a SpatRaster
rasterizeWin

Rasterize points with a moving window
plotRGB

Red-Green-Blue plot of a multi-layered SpatRaster
sources

Data sources of a SpatRaster
patches

Detect patches (clumps) of cells
perim

Perimeter or length
rcl

Combine row, column, and layer numbers
extremes

Get or compute the minimum and maximum cell values
symdif

Symmetrical difference
plot_graticule

Plot a graticule
rescale

rescale
xmin

Get or set single values of an extent
tapp

Apply a function to subsets of layers of a SpatRaster
scatterplot

Scatterplot of two SpatRaster layers
predict

Spatial model predictions
rotate

Rotate data along longitude
project

Change the coordinate reference system
rasterize

Rasterize vector data
rasterizeGeom

Rasterize geometric properties of vector data
scoff

Scale (gain) and offset
sharedPaths

Shared paths
options

Options
tmpFiles

Temporary files
terrain

terrain characteristics
normalize.longitude

normalize vector data that crosses the dateline
shift

Shift
viewshed

Compute a viewshed
sds

Create a SpatRasterDataset
sieve

Sieve filter
spatSample

Take a regular sample
sapp

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

spin a SpatVector
setValues

Set the values of raster cells or of geometry attributes
shade

Hill shading
replace_dollar

Replace with $<-
replace_values

Replace values of a SpatRaster
serialize

serialize and saveRDS for SpatRaster and SpatVector
subset

Subset a SpatRaster or a SpatVector
resample

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

simplifyGeom geometries
quantile

Quantiles of spatial data
where

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

Subset a SpatRaster or a SpatVector
subset_dollar

Subset a SpatRaster or a SpatVector
unique

Unique values
voronoi

Voronoi diagram and Delaunay triangles
split

Split
subst

replace cell values
units

units of SpatRaster or SpatRasterDataSet
query

Query a SpatVectorProxy object
trim

Trim a SpatRaster
replace_layers

Replace layers or variables
terra-package

Description of the methods in the terra package
summarize

Summarize
rep

Replicate layers
relate

Spatial relationships between geometries
sbar

scale bar
time

time of SpatRaster layers
scale

Scale values
summary

summary
selectRange

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

Zoom in on a map
zonal

Zonal statistics
which.lyr

Which cells are TRUE?
vect

Create SpatVector objects
vector_layers

List or remove layers from a vector file
xyRowColCell

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

SpatVector geometric properties
window

Set a window
union

Union SpatVector or SpatExtent objects
svc

Create a SpatVectorCollection
vrt

Virtual Raster Dataset
text

Add labels to a map
weighted.mean

Weighted mean of layers
writeRaster

Write raster data to a file
writeVector

Write SpatVector data to a file
wrap

wrap and unwrap
transpose

Transpose
sel

Spatial selection
selectHighest

select cells with high or low values
sprc

Create a SpatRasterCollection
stretch

Stretch
topology

Vector topology methods
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
update

Change values in a file
values

Cell values and geometry attributes
writeCDF

Write raster data to a NetCDF file