Learn R Programming

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

terra (version 1.6-53)

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-53

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

January 17th, 2023

Functions in terra (1.6-53)

RGB

Layers representing colors
add

Add (in place) a SpatRaster to another SpatRaster object
SpatVector-class

Class "SpatVector"
SpatExtent-class

Class "SpatExtent"
adjacent

Adjacent cells
SpatRaster-class

SpatRaster class
NAflag

Set the NA flag
align

Align a SpatExtent
app

Apply a function to the cells of a SpatRaster
activeCat

Active category
aggregate

Aggregate raster or vector data
animate

Animate a SpatRaster
Arith-methods

Arithmetic
as.spatvector

Conversion to a SpatVector, or to another SpatVector type
approximate

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

Coerce to a "raster" object
all.equal

Compare two SpatRasters for equality
as.character

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

SpatRaster* or SpatVector to list
as.data.frame

SpatRaster or SpatVector to data.frame
boxplot

Box plot of SpatRaster data
cartogram

Cartogram
c

Combine SpatRaster or SpatVector objects
atan2

Two argument arc-tangent
barplot

Bar plot of a SpatRaster
tighten

tighten SpatRaster or SpatRasterDataset objects
autocorrelation

Spatial autocorrelation
colors

Color table
catalyze

Factors to numeric
cellSize

Area covered by each raster cell
buffer

Create a buffer around vector geometries or raster patches
boundaries

Detect boundaries (edges)
coerce

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

Combine geometries
click

Query by clicking on a map
Compare-methods

Compare and logical methods
crs

Get or set a coordinate reference system
clamp

Clamp values
crosstab

Cross-tabulate
contour

Contour plot
classify

Classify (or reclassify) cell values
convHull

Convex hull and minimal rotated rectangle
depth

depth of SpatRaster layers
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
deepcopy

Deep copy
densify

Add additional nodes to lines or polygons
diff

Lagged differences
describe

describe
compareGeom

Compare geometries of SpatRasters
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
costDist

Cost distance
concats

Concatenate categorical rasters
density

Density plot
centroids

Centroids
cells

Get cell numbers
distance

Geographic distance
extract

Extract values from a SpatRaster
deprecated

deprecated methods
erase

Erase parts of a SpatVector object
ext

Create, get or set a SpatExtent
crop

Cut out a geographic subset
dots

Make a dot-density map
cover

Replace values with values from another object
focalMat

Focal weights matrix
extend

Extend
flip

Flip or reverse a raster
focalPairs

Focal function across two layers
focal

Focal values
expanse

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

Remove holes from polygons
geomtype

Geometry type of a SpatVector
direction

Direction
disagg

Disaggregate raster cells or vector geometries
gdal

GDAL version, supported file formats, and cache size
impose

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

Initialize a SpatRaster with values
global

global statistics
draw

Draw a polygon, line, extent, or points
geom

Get the geometry (coordinates) of a SpatVector
fillTime

Fill time gaps in a SpatRaster
ifel

ifelse for SpatRasters
elongate

elongate lines
focalReg

Focal regression
factors

Categorical rasters
image

SpatRaster image method
lines

Add SpatVector data to a map
is.bool

Raster value types
focalValues

Get focal values
headtail

head and tail of a SpatRaster or SpatVector
valid

Check or fix polygon or extent validity
lapp

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

Make tiles
freq

Frequency table
focal3D

Three-dimensional focal values
extremes

Get or compute the minimum and maximum cell values
focalCpp

Compute focal values with an iterating C++ function
is.lonlat

Check for longitude/latitude crs
modal

modal value
gaps

Find gaps between polygons
mosaic

mosaic SpatRasters
inplace

Change values in-place
na.omit

na.omit for SpatVector
Math-methods

General mathematical methods
inset

Make an inset map
mem

Memory available and needed
mask

Mask values in a SpatRaster or SpatVector
normalize.longitude

normalize vector data that crosses the dateline
north

North arrow
plotRGB

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

Plot a SpatExtent
perim

Perimeter or length
persp

Perspective plot
match

Value matching for SpatRasters
rasterize

Rasterize vector data
graticule

Create a graticule
hist

Histogram
relate

Spatial relationships between geometries
project

Change the coordinate reference system
interpIDW

Interpolate points using a moving window
interpNear

Nearest neighbor interpolation
quantile

Quantiles of spatial data
gridDistance

Distance on a grid
rasterizeWin

Rasterize points with a moving window
pairs

Pairs plot (matrix of scatterplots)
rasterizeGeom

Rasterize geometric properties of vector data
patches

Detect patches (clumps) of cells
interpolation

Spatial interpolation
rcl

Combine row, column, and layer numbers
sapp

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

Replace values of a SpatRaster
query

Query a SpatVectorProxy object
rep

Replicate layers
rangeFill

Fill layers with a range
layerCor

Correlation and (weighted) covariance
rescale

rescale
sbar

scale bar
linearUnits

Linear units of the coordinate reference system
intersect

Intersection
scale

Scale values
makeVRT

Make a VRT header file
map.pal

map.pal arrow
scatterplot

Scatterplot of two SpatRaster layers
roll

Rolling (moving) functions
merge

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

Range-apply
resample

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

simplifyGeom geometries
sort

Sort a SpatRaster
serialize

serialize and saveRDS for SpatRaster and SpatVector
setValues

Set the values of raster cells or of geometry attributes
mergeTime

merge SpatRasters by timelines to create a single timeseries
rast

Create a SpatRaster
replace_dollar

Replace with $<-
shade

Hill shading
sharedPaths

Shared paths
not.na

is not NA
replace_layers

Replace layers or variables
scoff

Scale (gain) and offset
stretch

Stretch
subset

Subset a SpatRaster or a SpatVector
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
selectHighest

select cells with high or low values
selectRange

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

Create a SpatRasterDataset
subst

replace cell values
split

Split
origin

Origin
sprc

Create a SpatRasterCollection
subset_dollar

Subset a SpatRaster or a SpatVector
text

Add labels to a map
time

time of SpatRaster layers
subset_double

Subset a SpatRaster or a SpatVector
names

Names of Spat* objects
plot_graticule

Plot a graticule
tapp

Apply a function to subsets of layers of a SpatRaster
terra-package

Description of the methods in the terra package
vector_layers

List or remove layers from a vector file
viewshed

Compute a viewshed
predict

Spatial model predictions
which.lyr

Which cells are TRUE?
transpose

Transpose
trim

Trim a SpatRaster
readwrite

Read from, or write to, file
nearest

nearby geometries
width

SpatVector geometric properties
plet

Plot with leaflet
plot

Make a map
sources

Data sources of a SpatRaster
spin

spin a SpatVector
rectify

Rectify a SpatRaster
summarize

Summarize
values

Cell values and geometry attributes
vect

Create SpatVector objects
weighted.mean

Weighted mean of layers
summary

summary
rotate

Rotate data along longitude
where

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

Take a regular sample
units

units of SpatRaster or SpatRasterDataSet
segregate

segregate
update

Change values in a file
sel

Spatial selection
options

Options
shift

Shift
terrain

terrain characteristics
xyRowColCell

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

Zonal statistics
writeVector

Write SpatVector data to a file
xmin

Get or set single values of an extent
sieve

Sieve filter
svc

Create a SpatVectorCollection
symdif

Symmetrical difference
union

Union SpatVector or SpatExtent objects
unique

Unique values
tmpFiles

Temporary files
topology

Vector topology methods
writeCDF

Write raster data to a NetCDF file
writeRaster

Write raster data to a file
zoom

Zoom in on a map
voronoi

Voronoi diagram and Delaunay triangles
vrt

Virtual Raster Dataset
window

Set a window
wrap

wrap and unwrap