Learn R Programming

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

terra (version 1.6-47)

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

183,196

Version

1.6-47

License

GPL (>= 3)

Maintainer

Last Published

December 2nd, 2022

Functions in terra (1.6-47)

NAflag

Set the NA flag
SpatVector-class

Class "SpatVector"
RGB

Layers representing colors
activeCat

Active category
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
app

Apply a function to the cells of a SpatRaster
all.equal

Compare two SpatRasters for equality
SpatRaster-class

SpatRaster class
Arith-methods

Arithmetic
approximate

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

Coerce to a "raster" object
as.data.frame

SpatRaster or SpatVector to data.frame
as.spatvector

Conversion to a SpatVector, or to another SpatVector type
animate

Animate a SpatRaster
cartogram

Cartogram
as.character

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

Combine SpatRaster or SpatVector objects
cellSize

Area covered by each raster cell
atan2

Two argument arc-tangent
as.list

SpatRaster* or SpatVector to list
catalyze

Factors to numeric
barplot

Bar plot of a SpatRaster
clamp

Clamp values
autocorrelation

Spatial autocorrelation
click

Query by clicking on a map
coerce

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

Combine geometries
cells

Get cell numbers
boxplot

Box plot of SpatRaster data
classify

Classify (or reclassify) cell values
buffer

Create a buffer around vector geometries or raster patches
compareGeom

Compare geometries of SpatRasters
boundaries

Detect boundaries (edges)
colors

Color table
tighten

tighten SpatRaster or SpatRasterDataset objects
deprecated

deprecated methods
crosstab

Cross-tabulate
crs

Get or set a coordinate reference system
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
contour

Contour plot
direction

Direction
density

Density plot
convHull

Convex hull and minimal rotated rectangle
diff

Lagged differences
centroids

Centroids
erase

Erase parts of a SpatVector object
costDist

Cost distance
disagg

Disaggregate raster cells or vector geometries
concats

Concatenate categorical rasters
expanse

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

global statistics
deepcopy

Deep copy
extract

Extract values from a SpatRaster
distance

Geographic distance
factors

Categorical rasters
geomtype

Geometry type of a SpatVector
fillHoles

Remove holes from polygons
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
dots

Make a dot-density map
densify

Add additional nodes to lines or polygons
focal3D

Three-dimensional focal values
gaps

Find gaps between polygons
draw

Draw a polygon, line, extent, or points
is.bool

Raster value types
Compare-methods

Compare and logical methods
fillTime

Fill time gaps in a SpatRaster
elongate

elongate lines
graticule

Create a graticule
is.lonlat

Check for longitude/latitude crs
lines

Add SpatVector data to a map
describe

describe
focalCpp

Compute focal values with an iterating C++ function
focalValues

Get focal values
gridDistance

Distance on a grid
focalMat

Focal weights matrix
crop

Cut out a geographic subset
focalReg

Focal regression
focalPairs

Focal function across two layers
cover

Replace values with values from another object
head and tail

Show the head or tail of a Spat* object
impose

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

Histogram
mosaic

mosaic SpatRasters
modal

modal value
freq

Frequency table
layerCor

Correlation and (weighted) covariance
Spatial interpolation

Spatial interpolation
patches

Detect patches (clumps) of cells
initialize

Initialize a SpatRaster with values
names

Names of Spat* objects
interpIDW

Interpolate points using a moving window
inplace

Change values in-place
depth

depth of SpatRaster layers
intersect

Intersection
linearUnits

Linear units of the coordinate reference system
match

Value matching for SpatRasters
Math-methods

General mathematical methods
interpNear

Nearest neighbor interpolation
rectify

Rectify a SpatRaster
makeTiles

Make tiles
focal

Focal values
valid

Check or fix polygon validity
mergeTime

merge SpatRasters by timelines to create a single timeseries
extremes

Get or compute the minimum and maximum cell values
inset

Make an inset map
predict

Spatial model predictions
lapp

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

GDAL version, supported file formats, and cache size
which.lyr

Which cells are TRUE?
perim

Perimeter or length
text

Add labels to a map
origin

Origin
plotRGB

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

Hill shading
relate

Spatial relationships between geometries
mem

Memory available and needed
tapp

Apply a function to subsets of layers of a SpatRaster
quantile

Quantiles of spatial data
merge

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

Perspective plot
query

Query a SpatVectorProxy object
symdif

Symmetrical difference
plet

Plot with leaflet
ext

Create, get or set a SpatExtent
pairs

Pairs plot (matrix of scatterplots)
makeVRT

Make a VRT header file
rasterizeGeom

Rasterize geometric properties of vector data
subset

Subset a SpatRaster or a SpatVector
sort

Sort a SpatRaster
rcl

Combine row, column, and layer numbers
spatSample

Take a regular sample
setValues

Set the values of raster cells or of geometry attributes
rast

Create a SpatRaster
extend

Extend
mask

Mask values in a SpatRaster or SpatVector
rangeFill

Fill layers with a range
north

North arrow
rapp

Range-apply
serialize

serialize and saveRDS for SpatRaster and SpatVector
scatterplot

Scatterplot of two SpatRaster layers
read and write

Read from, or write to, file
plot

Make a map
replace_values

Replace values of a SpatRaster
rep

Replicate layers
replace_dollar

Replace with $<-
sieve

Sieve filter
terra-package

Description of the methods in the terra package
flip

Flip or reverse a raster
not.na

is not NA
ifel

ifelse for SpatRasters
geom

Get the geometry (coordinates) of a SpatVector
rasterize

Rasterize vector data
subset_double

Subset a SpatRaster or a SpatVector
split

Split
union

Union SpatVector or SpatExtent objects
project

Change the coordinate reference system
sapp

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

Plot a SpatExtent
resample

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

simplifyGeom geometries
na.omit

na.omit for SpatVector
sprc

Create a SpatRasterCollection
rasterizeWin

Rasterize points with a moving window
replace_layers

Replace layers or variables
scoff

Scale (gain) and offset
rescale

rescale
image

SpatRaster image method
terrain

terrain characteristics
spin

spin a SpatVector
sharedPaths

Shared paths
rotate

Rotate data along longitude
subset_dollar

Subset a SpatRaster or a SpatVector
selectRange

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

Write raster data to a file
stretch

Stretch
sources

Data sources of a SpatRaster
topology

Vector topology methods
trim

Trim a SpatRaster
transpose

Transpose
roll

Rolling (moving) functions
summary

summary
svc

Create a SpatVectorCollection
update

Change values in a file
values

Cell values and geometry attributes
sds

Create a SpatRasterDataset
unique

Unique values
units

units of SpatRaster or SpatRasterDataSet
writeVector

Write SpatVector data to a file
xmin

Get or set single values of an extent
zoom

Zoom in on a map
vect

Create SpatVector objects
shift

Shift
zonal

Zonal statistics
xyRowColCell

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

Options
vector_layers

List or remove layers from a vector file
width

SpatVector geometric properties
window

Set a window
vrt

Virtual Raster Dataset
weighted.mean

Weighted mean of layers
normalize.longitude

normalize vector data that crosses the dateline
voronoi

Voronoi diagram and Delaunay triangles
viewshed

Compute a viewshed
nearest

nearby geometries
segregate

segregate
sel

Spatial selection
plot_graticule

Plot a graticule
sbar

scale bar
scale

Scale values
selectHighest

select cells with high or low values
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
wrap

wrap and unwrap
subst

replace cell values
summarize

Summarize
where

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

time of SpatRaster layers
tmpFiles

Temporary files
writeCDF

Write raster data to a NetCDF file