Learn R Programming

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

terra (version 1.7-71)

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

License

GPL (>= 3)

Maintainer

Last Published

January 31st, 2024

Functions in terra (1.7-71)

RGB

Layers representing colors
as.list

Coerce a Spat* object to a list
as.points

Conversion to a SpatVector of points
app

Apply a function to the cells of a SpatRaster
Arith-methods

Arithmetic
as.character

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

Box plot of SpatRaster data
add_box

draw a box
buffer

Create a buffer around vector geometries or raster patches
as.polygons

Conversion to a SpatVector of polygons
approximate

Estimate values for cell values that are NA by interpolating between layers
barplot

Bar plot of a SpatRaster
as.raster

Coerce to a "raster" object
all.equal

Compare two SpatRasters for equality
click

Query by clicking on a map
animate

Animate a SpatRaster
as.lines

Conversion to a SpatVector of lines
centroids

Centroids
as.data.frame

SpatRaster or SpatVector to data.frame
c

Combine SpatRaster or SpatVector objects
autocorrelation

Spatial autocorrelation
atan2

Two argument arc-tangent
cartogram

Cartogram
catalyze

Factors to numeric
boundaries

Detect boundaries (edges)
clamp_ts

clamp time series data
compareGeom

Compare geometries of SpatRasters
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
coerce

Coercion to vector, matrix or array
classify

Classify (or reclassify) cell values
costDist

Cost distance
clamp

Clamp values
cover

Replace values with values from another object
cellSize

Area covered by each raster cell
datatype

Data type of a SpatRaster or SpatVector
cells

Get cell numbers
contour

Contour plot
convHull

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

Deep copy
combineGeoms

Combine geometries
deprecated

deprecated methods
Compare-methods

Compare and logical methods
concats

Concatenate categorical rasters
depth

depth of SpatRaster layers
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
tighten

tighten SpatRaster or SpatRasterDataset objects
colors

Color table
disagg

Disaggregate raster cells or vector geometries
crosstab

Cross-tabulate
crop

Cut out a geographic subset
crs

Get or set a coordinate reference system
distance

Geographic distance
expanse

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

elongate lines
densify

Add additional nodes to lines or polygons
dots

Make a dot-density map
erase

Erase parts of a SpatVector object
draw

Draw a polygon, line, extent, or points
density

Density plot
focalPairs

Focal function across two layers
extend

Extend
describe

describe
diff

Lagged differences
factors

Categorical rasters
ext

Create, get or set a SpatExtent
focalCpp

Compute focal values with an iterating C++ function
direction

Direction
extract

Extract values from a SpatRaster
extractAlong

extract values along lines
global

global statistics
geomtype

Geometry type of a SpatVector
fillHoles

Remove holes from polygons
focalReg

Focal regression
extractRange

Extract values for a range of layers from a SpatRaster
focal

Focal values
freq

Frequency table
fillTime

Fill time gaps in a SpatRaster
gdal

GDAL version, supported file formats, and cache size
focalMat

Focal weights matrix
gaps

Find gaps between polygons
focal3D

Three-dimensional focal values
geom

Get the geometry (coordinates) of a SpatVector
graticule

Create a graticule
interpIDW

Interpolate points using a moving window
gridDistance

Distance on a grid
hist

Histogram
inplace

Change values in-place
identical

Compare two SpatRasters for equality
flip

Flip or reverse a raster
impose

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

Get focal values
forceCCW

force counter-clockwise polygons
is.lonlat

Check for longitude/latitude crs
initialize

Initialize a SpatRaster with values
interpNear

Nearest neighbor interpolation
inset

Make an inset map
ifel

ifelse for SpatRasters
add_legend

add a custom legend
linearUnits

Linear units of the coordinate reference system
is.rotated

Check for rotation
makeVRT

Make a VRT header file
lines

Add points, lines, or polygons to a map
is.bool

Raster value types
map.pal

map.pal arrow
image

SpatRaster image method
extremes

Get or compute the minimum and maximum cell values
modal

modal value
mask

Mask values in a SpatRaster or SpatVector
halo

Add halo-ed text to a plot
is.empty

Check if a SpatExtent or SpatVector is empty
match

Value matching for SpatRasters
normalize.longitude

normalize vector data that crosses the dateline
persp

Perspective plot
north

North arrow
mosaic

mosaic SpatRasters
plet

Plot with leaflet
makeTiles

Make tiles or get their extents
na.omit

Find and remove geometries that are NA
princomp

SpatRaster PCA with princomp
is.valid

Check or fix polygon or extent validity
project

Change the coordinate reference system
headtail

head and tail of a SpatRaster or SpatVector
pairs

Pairs plot (matrix of scatterplots)
interpolation

Spatial interpolation
intersect

Intersection
lapp

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

Correlation and (weighted) covariance
Math-methods

General mathematical methods
panel

Map panel
mem

Memory available and needed
names

Names of Spat* objects
k_means

k_means
nearest

nearby geometries
meta

meta
metags

Set or get metadata
rast

Create a SpatRaster
merge

Merge SpatRasters, or merge a SpatVector with a data.frame
not.na

is not NA
patches

Detect patches (clumps) of cells
prcomp

SpatRaster PCA with prcomp
perim

Perimeter or length
quantile

Quantiles of spatial data
rasterize

Rasterize vector data
rectify

Rectify a SpatRaster
query

Query a SpatVectorProxy object
predict

Spatial model predictions
rcl

Combine row, column, and layer numbers
readwrite

Read from, or write to, file
rotate

Rotate data along longitude
regress

Cell level regression
mergeTime

merge SpatRasters by timelines to create a single timeseries
plot

Make a map
plotRGB

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

Origin
same.crs

Compare coordinate reference systems
relate

Spatial relationships between geometries
rep

Replicate layers
replace_dollar

Replace with $<-
replace_layers

Replace layers or variables
rangeFill

Fill layers with a range
rescale

rescale
spin

spin a SpatVector
roll

Rolling (moving) functions
sbar

scale bar
scale

Scale values
setValues

Set the values of raster cells or of geometry attributes
rapp

Range-apply
shade

Hill shading
subset

Subset a SpatRaster or a SpatVector
subset_dollar

Subset a SpatRaster or a SpatVector
plot_extent

Plot a SpatExtent
symdif

Symmetrical difference
plot_graticule

Plot a graticule
varnames

variable and long variable names
tapp

Apply a function to subsets of layers of a SpatRaster
rasterizeGeom

Rasterize geometric properties of vector data
rasterizeWin

Rasterize points with a moving window
selectRange

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

Split
vect

Create SpatVector objects
voronoi

Voronoi diagram and Delaunay triangles
vrt

Virtual Raster Dataset
summary

summary
writeVector

Write SpatVector data to a file
replace_values

Replace values of a SpatRaster
scatterplot

Scatterplot of two SpatRaster layers
svc

Create a SpatVectorCollection
scoff

Scale (gain) and offset
serialize

saveRDS and serialize for SpatVector and SpatRaster*
sort

Sort a SpatRaster or SpatVector
update

Change values in a file
spatSample

Take a regular sample
sources

Data sources of a SpatRaster
xapp

Apply a function to the cells of a two SpatRasters
topology

Vector topology methods
transpose

Transpose
subst

replace cell values
summarize

Summarize
time

time of SpatRaster layers
sds

Create a SpatRasterDataset
resample

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

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

segregate
values

Cell values and geometry attributes
trim

Trim a SpatRaster
tmpFiles

Temporary files
union

Union SpatVector or SpatExtent objects
vector_layers

List or remove layers from a vector file
viewshed

Compute a viewshed
sel

Spatial selection
width

SpatVector geometric properties
sieve

Sieve filter
wrap

wrap and unwrap
selectHighest

select cells with high or low values
wrapCache

SpatRaster wrap with caching options
sharedPaths

Shared paths
simplifyGeom

simplifyGeom geometries
shift

Shift
subset_double

Subset a SpatRaster or a SpatVector
sprc

Create a SpatRasterCollection
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
stretch

Stretch
window

Set a window
writeCDF

Write raster data to a NetCDF file
terra-package

Description of the methods in the terra package
options

Options
where

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

terrain characteristics
which.lyr

Which cells are TRUE?
text

Add labels to a map
unique

Unique values
xmin

Get or set single values of an extent
units

units of SpatRaster or SpatRasterDataSet
writeRaster

Write raster data to a file
vrt_tiles

filenames of VRT tiles
weighted.mean

Weighted mean of layers
zonal

Zonal statistics
xyRowColCell

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

Zoom in on a map
NAflag

Set the NA flag
aggregate

Aggregate raster or vector data
add

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

Adjacent cells
SpatExtent-class

Class "SpatExtent"
SpatVector-class

Class "SpatVector"
SpatRaster-class

SpatRaster class
align

Align a SpatExtent
activeCat

Active category