Learn R Programming

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

terra (version 1.7-18)

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

202,413

Version

1.7-18

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

March 6th, 2023

Functions in terra (1.7-18)

activeCat

Active category
SpatExtent-class

Class "SpatExtent"
aggregate

Aggregate raster or vector data
align

Align a SpatExtent
add

Add (in place) a SpatRaster to another SpatRaster object
all.equal

Compare two SpatRasters for equality
c

Combine SpatRaster or SpatVector objects
adjacent

Adjacent cells
cartogram

Cartogram
animate

Animate a SpatRaster
boxplot

Box plot of SpatRaster data
SpatRaster-class

SpatRaster class
buffer

Create a buffer around vector geometries or raster patches
as.data.frame

SpatRaster or SpatVector to data.frame
as.raster

Coerce to a "raster" object
as.list

SpatRaster* or SpatVector to list
Arith-methods

Arithmetic
classify

Classify (or reclassify) cell values
clamp

Clamp values
coerce

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

Set the NA flag
as.character

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

Query by clicking on a map
crs

Get or set a coordinate reference system
tighten

tighten SpatRaster or SpatRasterDataset objects
deepcopy

Deep copy
RGB

Layers representing colors
extend

Extend
clamp_ts

clamp time series data
concats

Concatenate categorical rasters
contour

Contour plot
crop

Cut out a geographic subset
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
app

Apply a function to the cells of a SpatRaster
catalyze

Factors to numeric
approximate

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

Cross-tabulate
direction

Direction
expanse

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

Create, get or set a SpatExtent
atan2

Two argument arc-tangent
extract

Extract values from a SpatRaster
autocorrelation

Spatial autocorrelation
as.spatvector

Conversion to a SpatVector, or to another SpatVector type
barplot

Bar plot of a SpatRaster
cells

Get cell numbers
deprecated

deprecated methods
focalPairs

Focal function across two layers
depth

depth of SpatRaster layers
cellSize

Area covered by each raster cell
centroids

Centroids
costDist

Cost distance
focalReg

Focal regression
geom

Get the geometry (coordinates) of a SpatVector
gaps

Find gaps between polygons
geomtype

Geometry type of a SpatVector
cover

Replace values with values from another object
densify

Add additional nodes to lines or polygons
convHull

Convex hull and minimal rotated rectangle
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
gdal

GDAL version, supported file formats, and cache size
interpNear

Nearest neighbor interpolation
boundaries

Detect boundaries (edges)
colors

Color table
describe

describe
diff

Lagged differences
combineGeoms

Combine geometries
interpolation

Spatial interpolation
disagg

Disaggregate raster cells or vector geometries
density

Density plot
Compare-methods

Compare and logical methods
compareGeom

Compare geometries of SpatRasters
dots

Make a dot-density map
linearUnits

Linear units of the coordinate reference system
distance

Geographic distance
draw

Draw a polygon, line, extent, or points
lines

Add points, lines, or polygons to a map
initialize

Initialize a SpatRaster with values
match

Value matching for SpatRasters
Math-methods

General mathematical methods
elongate

elongate lines
pairs

Pairs plot (matrix of scatterplots)
fillTime

Fill time gaps in a SpatRaster
flip

Flip or reverse a raster
focalCpp

Compute focal values with an iterating C++ function
panel

Map panel
global

global statistics
erase

Erase parts of a SpatVector object
graticule

Create a graticule
focalMat

Focal weights matrix
is.lonlat

Check for longitude/latitude crs
valid

Check or fix polygon or extent validity
inplace

Change values in-place
makeTiles

Make tiles
plot

Make a map
inset

Make an inset map
focal

Focal values
extremes

Get or compute the minimum and maximum cell values
makeVRT

Make a VRT header file
focal3D

Three-dimensional focal values
plotRGB

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

Distance on a grid
modal

modal value
not.na

is not NA
origin

Origin
headtail

head and tail of a SpatRaster or SpatVector
predict

Spatial model predictions
factors

Categorical rasters
normalize.longitude

normalize vector data that crosses the dateline
interpIDW

Interpolate points using a moving window
project

Change the coordinate reference system
fillHoles

Remove holes from polygons
rcl

Combine row, column, and layer numbers
image

SpatRaster image method
intersect

Intersection
focalValues

Get focal values
is.bool

Raster value types
readwrite

Read from, or write to, file
sds

Create a SpatRasterDataset
north

North arrow
segregate

segregate
freq

Frequency table
mem

Memory available and needed
patches

Detect patches (clumps) of cells
sieve

Sieve filter
simplifyGeom

simplifyGeom geometries
merge

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

Subset a SpatRaster or a SpatVector
quantile

Quantiles of spatial data
perim

Perimeter or length
rasterizeGeom

Rasterize geometric properties of vector data
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
impose

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

Rasterize points with a moving window
rangeFill

Fill layers with a range
lapp

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

Correlation and (weighted) covariance
mergeTime

merge SpatRasters by timelines to create a single timeseries
query

Query a SpatVectorProxy object
rectify

Rectify a SpatRaster
symdif

Symmetrical difference
meta

meta
resample

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

Apply a function to subsets of layers of a SpatRaster
rapp

Range-apply
hist

Histogram
ifel

ifelse for SpatRasters
replace_layers

Replace layers or variables
map.pal

map.pal arrow
replace_values

Replace values of a SpatRaster
writeRaster

Write raster data to a file
names

Names of Spat* objects
relate

Spatial relationships between geometries
writeVector

Write SpatVector data to a file
nearest

nearby geometries
sel

Spatial selection
mask

Mask values in a SpatRaster or SpatVector
mosaic

mosaic SpatRasters
plot_extent

Plot a SpatExtent
rescale

rescale
sbar

scale bar
na.omit

na.omit for SpatVector
persp

Perspective plot
plot_graticule

Plot a graticule
selectHighest

select cells with high or low values
sort

Sort a SpatRaster or SpatVector
plet

Plot with leaflet
sources

Data sources of a SpatRaster
roll

Rolling (moving) functions
rotate

Rotate data along longitude
sharedPaths

Shared paths
sprc

Create a SpatRasterCollection
scale

Scale values
shift

Shift
stretch

Stretch
topology

Vector topology methods
subst

replace cell values
selectRange

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

Summarize
serialize

serialize and saveRDS for SpatRaster and SpatVector
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
transpose

Transpose
summary

summary
time

time of SpatRaster layers
tmpFiles

Temporary files
svc

Create a SpatVectorCollection
update

Change values in a file
values

Cell values and geometry attributes
subset

Subset a SpatRaster or a SpatVector
width

SpatVector geometric properties
subset_dollar

Subset a SpatRaster or a SpatVector
unique

Unique values
window

Set a window
rast

Create a SpatRaster
units

units of SpatRaster or SpatRasterDataSet
terrain

terrain characteristics
wrap

wrap and unwrap
xmin

Get or set single values of an extent
xyRowColCell

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

Add labels to a map
writeCDF

Write raster data to a NetCDF file
rasterize

Rasterize vector data
where

Where are the cells with the min or max values?
which.lyr

Which cells are TRUE?
vect

Create SpatVector objects
vector_layers

List or remove layers from a vector file
rep

Replicate layers
replace_dollar

Replace with $<-
viewshed

Compute a viewshed
scatterplot

Scatterplot of two SpatRaster layers
voronoi

Voronoi diagram and Delaunay triangles
scoff

Scale (gain) and offset
setValues

Set the values of raster cells or of geometry attributes
shade

Hill shading
spin

spin a SpatVector
split

Split
terra-package

Description of the methods in the terra package
options

Options
trim

Trim a SpatRaster
zonal

Zonal statistics
union

Union SpatVector or SpatExtent objects
zoom

Zoom in on a map
vrt

Virtual Raster Dataset
weighted.mean

Weighted mean of layers
SpatVector-class

Class "SpatVector"