Learn R Programming

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

terra (version 1.7-65)

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

License

GPL (>= 3)

Maintainer

Last Published

December 15th, 2023

Functions in terra (1.7-65)

as.data.frame

SpatRaster or SpatVector to data.frame
Arith-methods

Arithmetic
app

Apply a function to the cells of a SpatRaster
as.lines

Conversion to a SpatVector of lines
as.character

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

Coerce a Spat* object to a list
as.points

Conversion to a SpatVector of points
barplot

Bar plot of a SpatRaster
all.equal

Compare two SpatRasters for equality
approximate

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

Conversion to a SpatVector of polygons
as.raster

Coerce to a "raster" object
animate

Animate a SpatRaster
boundaries

Detect boundaries (edges)
c

Combine SpatRaster or SpatVector objects
coerce

Coercion to vector, matrix or array
boxplot

Box plot of SpatRaster data
buffer

Create a buffer around vector geometries or raster patches
catalyze

Factors to numeric
cellSize

Area covered by each raster cell
cells

Get cell numbers
cartogram

Cartogram
clamp

Clamp values
tighten

tighten SpatRaster or SpatRasterDataset objects
costDist

Cost distance
convHull

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

clamp time series data
compareGeom

Compare geometries of SpatRasters
autocorrelation

Spatial autocorrelation
crs

Get or set a coordinate reference system
classify

Classify (or reclassify) cell values
concats

Concatenate categorical rasters
Compare-methods

Compare and logical methods
centroids

Centroids
contour

Contour plot
atan2

Two argument arc-tangent
depth

depth of SpatRaster layers
density

Density plot
describe

describe
deprecated

deprecated methods
crop

Cut out a geographic subset
colors

Color table
distance

Geographic distance
combineGeoms

Combine geometries
click

Query by clicking on a map
dots

Make a dot-density map
deepcopy

Deep copy
densify

Add additional nodes to lines or polygons
cover

Replace values with values from another object
datatype

Data type of a SpatRaster or SpatVector
fillHoles

Remove holes from polygons
erase

Erase parts of a SpatVector object
expanse

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

Extract values for a range of layers from a SpatRaster
flip

Flip or reverse a raster
focal

Focal values
diff

Lagged differences
crosstab

Cross-tabulate
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
factors

Categorical rasters
forceCCW

force counter-clockwise polygons
direction

Direction
gdal

GDAL version, supported file formats, and cache size
freq

Frequency table
gaps

Find gaps between polygons
disagg

Disaggregate raster cells or vector geometries
interpolation

Spatial interpolation
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
fillTime

Fill time gaps in a SpatRaster
intersect

Intersection
focalReg

Focal regression
is.valid

Check or fix polygon or extent validity
ifel

ifelse for SpatRasters
k_means

k_means
image

SpatRaster image method
Math-methods

General mathematical methods
mem

Memory available and needed
mosaic

mosaic SpatRasters
draw

Draw a polygon, line, extent, or points
extract

Extract values from a SpatRaster
extractAlong

extract values along lines
focalValues

Get focal values
focalMat

Focal weights matrix
global

global statistics
focalPairs

Focal function across two layers
gridDistance

Distance on a grid
geom

Get the geometry (coordinates) of a SpatVector
elongate

elongate lines
graticule

Create a graticule
inplace

Change values in-place
na.omit

Find and remove geometries that are NA
inset

Make an inset map
halo

Add halo-ed text to a plot
geomtype

Geometry type of a SpatVector
patches

Detect patches (clumps) of cells
interpIDW

Interpolate points using a moving window
impose

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

Create, get or set a SpatExtent
perim

Perimeter or length
add_legend

add a custom legend
interpNear

Nearest neighbor interpolation
lines

Add points, lines, or polygons to a map
makeTiles

Make tiles
initialize

Initialize a SpatRaster with values
rapp

Range-apply
linearUnits

Linear units of the coordinate reference system
focal3D

Three-dimensional focal values
extend

Extend
lapp

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

Correlation and (weighted) covariance
mask

Mask values in a SpatRaster or SpatVector
normalize.longitude

normalize vector data that crosses the dateline
merge

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

Create a SpatRaster
is.lonlat

Check for longitude/latitude crs
is.rotated

Check for rotation
match

Value matching for SpatRasters
makeVRT

Make a VRT header file
mergeTime

merge SpatRasters by timelines to create a single timeseries
replace_layers

Replace layers or variables
replace_values

Replace values of a SpatRaster
north

North arrow
map.pal

map.pal arrow
not.na

is not NA
names

Names of Spat* objects
focalCpp

Compute focal values with an iterating C++ function
headtail

head and tail of a SpatRaster or SpatVector
scale

Scale values
origin

Origin
scatterplot

Scatterplot of two SpatRaster layers
shade

Hill shading
extremes

Get or compute the minimum and maximum cell values
sharedPaths

Shared paths
predict

Spatial model predictions
hist

Histogram
is.bool

Raster value types
is.empty

Check if a SpatExtent or SpatVector is empty
plot

Make a map
shift

Shift
plotRGB

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

Sieve filter
nearest

nearby geometries
tapp

Apply a function to subsets of layers of a SpatRaster
plot_extent

Plot a SpatExtent
terra-package

Description of the methods in the terra package
meta

meta
plot_graticule

Plot a graticule
query

Query a SpatVectorProxy object
modal

modal value
princomp

SpatRaster PCA
rangeFill

Fill layers with a range
rasterize

Rasterize vector data
metags

Set or get metadata
pairs

Pairs plot (matrix of scatterplots)
union

Union SpatVector or SpatExtent objects
unique

Unique values
rep

Replicate layers
persp

Perspective plot
values

Cell values and geometry attributes
plet

Plot with leaflet
varnames

variable and long variable names
panel

Map panel
project

Change the coordinate reference system
quantile

Quantiles of spatial data
replace_dollar

Replace with $<-
regress

Cell level regression
rasterizeWin

Rasterize points with a moving window
rcl

Combine row, column, and layer numbers
wrapCache

SpatRaster wrap with caching options
segregate

segregate
relate

Spatial relationships between geometries
roll

Rolling (moving) functions
rasterizeGeom

Rasterize geometric properties of vector data
rectify

Rectify a SpatRaster
readwrite

Read from, or write to, file
writeCDF

Write raster data to a NetCDF file
sel

Spatial selection
sapp

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

Compare coordinate reference systems
resample

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

Take a regular sample
serialize

saveRDS and serialize for SpatVector and SpatRaster*
rotate

Rotate data along longitude
scoff

Scale (gain) and offset
rescale

rescale
setValues

Set the values of raster cells or of geometry attributes
stretch

Stretch
sources

Data sources of a SpatRaster
subset

Subset a SpatRaster or a SpatVector
spin

spin a SpatVector
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
selectHighest

select cells with high or low values
sbar

scale bar
selectRange

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

Split
sds

Create a SpatRasterDataset
summarize

Summarize
sprc

Create a SpatRasterCollection
svc

Create a SpatVectorCollection
summary

summary
text

Add labels to a map
subset_dollar

Subset a SpatRaster or a SpatVector
subst

replace cell values
subset_double

Subset a SpatRaster or a SpatVector
time

time of SpatRaster layers
simplifyGeom

simplifyGeom geometries
sort

Sort a SpatRaster or SpatVector
units

units of SpatRaster or SpatRasterDataSet
tmpFiles

Temporary files
options

Options
symdif

Symmetrical difference
transpose

Transpose
update

Change values in a file
trim

Trim a SpatRaster
topology

Vector topology methods
vrt

Virtual Raster Dataset
which.lyr

Which cells are TRUE?
vrt_tiles

filenames of VRT tiles
weighted.mean

Weighted mean of layers
terrain

terrain characteristics
width

SpatVector geometric properties
window

Set a window
where

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

Get or set single values of an extent
vect

Create SpatVector objects
vector_layers

List or remove layers from a vector file
viewshed

Compute a viewshed
xyRowColCell

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

Voronoi diagram and Delaunay triangles
wrap

wrap and unwrap
zonal

Zonal statistics
writeRaster

Write raster data to a file
writeVector

Write SpatVector data to a file
zoom

Zoom in on a map
SpatExtent-class

Class "SpatExtent"
SpatVector-class

Class "SpatVector"
SpatRaster-class

SpatRaster class
aggregate

Aggregate raster or vector data
NAflag

Set the NA flag
RGB

Layers representing colors
add

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

Adjacent cells
activeCat

Active category
align

Align a SpatExtent