Learn R Programming

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

terra (version 1.7-37)

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

228,439

Version

1.7-37

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

June 18th, 2023

Functions in terra (1.7-37)

activeCat

Active category
adjacent

Adjacent cells
NAflag

Set the NA flag
SpatRaster-class

SpatRaster class
RGB

Layers representing colors
as.list

Coerce a Spat* object to a list
Arith-methods

Arithmetic
all.equal

Compare two SpatRasters for equality
as.points

Conversion to a SpatVector of points
c

Combine SpatRaster or SpatVector objects
cartogram

Cartogram
app

Apply a function to the cells of a SpatRaster
as.data.frame

SpatRaster or SpatVector to data.frame
cells

Get cell numbers
as.character

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

Box plot of SpatRaster data
approximate

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

Factors to numeric
atan2

Two argument arc-tangent
centroids

Centroids
concats

Concatenate categorical rasters
cellSize

Area covered by each raster cell
contour

Contour plot
autocorrelation

Spatial autocorrelation
deprecated

deprecated methods
colors

Color table
combineGeoms

Combine geometries
animate

Animate a SpatRaster
depth

depth of SpatRaster layers
buffer

Create a buffer around vector geometries or raster patches
extend

Extend
as.lines

Conversion to a SpatVector of lines
crop

Cut out a geographic subset
barplot

Bar plot of a SpatRaster
crosstab

Cross-tabulate
as.polygons

Conversion to a SpatVector of polygons
as.raster

Coerce to a "raster" object
clamp

Clamp values
cover

Replace values with values from another object
clamp_ts

clamp time series data
elongate

elongate lines
boundaries

Detect boundaries (edges)
erase

Erase parts of a SpatVector object
convHull

Convex hull and minimal rotated rectangle
geom

Get the geometry (coordinates) of a SpatVector
classify

Classify (or reclassify) cell values
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
geomtype

Geometry type of a SpatVector
densify

Add additional nodes to lines or polygons
ifel

ifelse for SpatRasters
click

Query by clicking on a map
Compare-methods

Compare and logical methods
extract

Extract values from a SpatRaster
costDist

Cost distance
crs

Get or set a coordinate reference system
density

Density plot
expanse

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

Create, get or set a SpatExtent
impose

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

Initialize a SpatRaster with values
deepcopy

Deep copy
compareGeom

Compare geometries of SpatRasters
disagg

Disaggregate raster cells or vector geometries
distance

Geographic distance
focalCpp

Compute focal values with an iterating C++ function
image

SpatRaster image method
focal

Focal values
describe

describe
focal3D

Three-dimensional focal values
coerce

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

Spatial interpolation
diff

Lagged differences
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
focalMat

Focal weights matrix
focalValues

Get focal values
tighten

tighten SpatRaster or SpatRasterDataset objects
direction

Direction
fillTime

Fill time gaps in a SpatRaster
focalPairs

Focal function across two layers
freq

Frequency table
mem

Memory available and needed
focalReg

Focal regression
gridDistance

Distance on a grid
dots

Make a dot-density map
merge

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

Intersection
extremes

Get or compute the minimum and maximum cell values
map.pal

map.pal arrow
halo

Add halo-ed text to a plot
mask

Mask values in a SpatRaster or SpatVector
is.bool

Raster value types
flip

Flip or reverse a raster
mosaic

mosaic SpatRasters
draw

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

Check or fix polygon or extent validity
lapp

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

modal value
linearUnits

Linear units of the coordinate reference system
patches

Detect patches (clumps) of cells
factors

Categorical rasters
perim

Perimeter or length
na.omit

na.omit for SpatVector
global

global statistics
is.lonlat

Check for longitude/latitude crs
lines

Add points, lines, or polygons to a map
match

Value matching for SpatRasters
names

Names of Spat* objects
Math-methods

General mathematical methods
nearest

nearby geometries
pairs

Pairs plot (matrix of scatterplots)
not.na

is not NA
graticule

Create a graticule
fillHoles

Remove holes from polygons
panel

Map panel
headtail

head and tail of a SpatRaster or SpatVector
origin

Origin
gaps

Find gaps between polygons
rasterizeGeom

Rasterize geometric properties of vector data
plot_extent

Plot a SpatExtent
rast

Create a SpatRaster
normalize.longitude

normalize vector data that crosses the dateline
north

North arrow
hist

Histogram
persp

Perspective plot
plet

Plot with leaflet
gdal

GDAL version, supported file formats, and cache size
rasterize

Rasterize vector data
relate

Spatial relationships between geometries
predict

Spatial model predictions
layerCor

Correlation and (weighted) covariance
inplace

Change values in-place
inset

Make an inset map
project

Change the coordinate reference system
add_legend

add a custom legend
rep

Replicate layers
makeTiles

Make tiles
rcl

Combine row, column, and layer numbers
readwrite

Read from, or write to, file
sbar

scale bar
sds

Create a SpatRasterDataset
scale

Scale values
makeVRT

Make a VRT header file
interpIDW

Interpolate points using a moving window
rasterizeWin

Rasterize points with a moving window
rotate

Rotate data along longitude
segregate

segregate
spin

spin a SpatVector
split

Split
scatterplot

Scatterplot of two SpatRaster layers
plot_graticule

Plot a graticule
scoff

Scale (gain) and offset
time

time of SpatRaster layers
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
selectRange

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

merge SpatRasters by timelines to create a single timeseries
sharedPaths

Shared paths
tmpFiles

Temporary files
serialize

saveRDS and serialize for SpatVector and SpatRaster*
sort

Sort a SpatRaster or SpatVector
shift

Shift
sources

Data sources of a SpatRaster
unique

Unique values
units

units of SpatRaster or SpatRasterDataSet
summary

summary
same.crs

Compare coordinate reference systems
sel

Spatial selection
subset_double

Subset a SpatRaster or a SpatVector
svc

Create a SpatVectorCollection
writeCDF

Write raster data to a NetCDF file
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
trim

Trim a SpatRaster
selectHighest

select cells with high or low values
meta

meta
interpNear

Nearest neighbor interpolation
union

Union SpatVector or SpatExtent objects
writeRaster

Write raster data to a file
plot

Make a map
width

SpatVector geometric properties
rangeFill

Fill layers with a range
terra-package

Description of the methods in the terra package
subset

Subset a SpatRaster or a SpatVector
subset_dollar

Subset a SpatRaster or a SpatVector
window

Set a window
xyRowColCell

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

Create SpatVector objects
options

Options
vector_layers

List or remove layers from a vector file
plotRGB

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

Zonal statistics
quantile

Quantiles of spatial data
query

Query a SpatVectorProxy object
writeVector

Write SpatVector data to a file
viewshed

Compute a viewshed
replace_dollar

Replace with $<-
xmin

Get or set single values of an extent
replace_layers

Replace layers or variables
rapp

Range-apply
rectify

Rectify a SpatRaster
voronoi

Voronoi diagram and Delaunay triangles
regress

Cell level regression
rescale

rescale
roll

Rolling (moving) functions
sieve

Sieve filter
simplifyGeom

simplifyGeom geometries
subst

replace cell values
summarize

Summarize
replace_values

Replace values of a SpatRaster
topology

Vector topology methods
transpose

Transpose
vrt

Virtual Raster Dataset
weighted.mean

Weighted mean of layers
wrap

wrap and unwrap
wrapCache

SpatRaster wrap with caching options
resample

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

Set the values of raster cells or of geometry attributes
shade

Hill shading
sprc

Create a SpatRasterCollection
stretch

Stretch
symdif

Symmetrical difference
tapp

Apply a function to subsets of layers of a SpatRaster
terrain

terrain characteristics
text

Add labels to a map
update

Change values in a file
values

Cell values and geometry attributes
where

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

Which cells are TRUE?
zoom

Zoom in on a map
add

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

Aggregate raster or vector data
SpatExtent-class

Class "SpatExtent"
SpatVector-class

Class "SpatVector"
align

Align a SpatExtent