Learn R Programming

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

terra (version 1.7-55)

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

144,883

Version

1.7-55

License

GPL (>= 3)

Maintainer

Last Published

October 13th, 2023

Functions in terra (1.7-55)

aggregate

Aggregate raster or vector data
RGB

Layers representing colors
activeCat

Active category
add

Add (in place) a SpatRaster to another SpatRaster object or to a SpatRasterDataset or SpatRasterCollection
as.data.frame

SpatRaster or SpatVector to data.frame
all.equal

Compare two SpatRasters for equality
as.raster

Coerce to a "raster" object
animate

Animate a SpatRaster
cartogram

Cartogram
adjacent

Adjacent cells
c

Combine SpatRaster or SpatVector objects
align

Align a SpatExtent
as.list

Coerce a Spat* object to a list
classify

Classify (or reclassify) cell values
barplot

Bar plot of a SpatRaster
Arith-methods

Arithmetic
as.lines

Conversion to a SpatVector of lines
click

Query by clicking on a map
convHull

Convex hull, minimal bounding rotated rectangle, and minimal bounding circle
Compare-methods

Compare and logical methods
boxplot

Box plot of SpatRaster data
boundaries

Detect boundaries (edges)
is.lonlat

Check for longitude/latitude crs
costDist

Cost distance
clamp_ts

clamp time series data
cells

Get cell numbers
SpatExtent-class

Class "SpatExtent"
centroids

Centroids
buffer

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

Conversion to a SpatVector of polygons
combineGeoms

Combine geometries
density

Density plot
colors

Color table
deprecated

deprecated methods
SpatRaster-class

SpatRaster class
as.character

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

Direction
as.points

Conversion to a SpatVector of points
clamp

Clamp values
names

Names of Spat* objects
cover

Replace values with values from another object
focal

Focal values
ext

Create, get or set a SpatExtent
disagg

Disaggregate raster cells or vector geometries
makeVRT

Make a VRT header file
compareGeom

Compare geometries of SpatRasters
draw

Draw a polygon, line, extent, or points
scatterplot

Scatterplot of two SpatRaster layers
datatype

Data type of a SpatRaster or SpatVector
catalyze

Factors to numeric
app

Apply a function to the cells of a SpatRaster
dots

Make a dot-density map
crosstab

Cross-tabulate
plot_graticule

Plot a graticule
approximate

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

Focal function across two layers
rasterizeGeom

Rasterize geometric properties of vector data
resample

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

Focal regression
extend

Extend
is.valid

Check or fix polygon or extent validity
impose

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

North arrow
normalize.longitude

normalize vector data that crosses the dateline
image

SpatRaster image method
sieve

Sieve filter
plot_extent

Plot a SpatExtent
crop

Cut out a geographic subset
deepcopy

Deep copy
topology

Vector topology methods
focalCpp

Compute focal values with an iterating C++ function
extremes

Get or compute the minimum and maximum cell values
densify

Add additional nodes to lines or polygons
erase

Erase parts of a SpatVector object
atan2

Two argument arc-tangent
focalValues

Get focal values
expanse

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

Area covered by each raster cell
concats

Concatenate categorical rasters
tighten

tighten SpatRaster or SpatRasterDataset objects
autocorrelation

Spatial autocorrelation
coerce

Coercion to vector, matrix or array
distance

Geographic distance
layerCor

Correlation and (weighted) covariance
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
replace_values

Replace values of a SpatRaster
gaps

Find gaps between polygons
contour

Contour plot
rasterizeWin

Rasterize points with a moving window
simplifyGeom

simplifyGeom geometries
crs

Get or set a coordinate reference system
trim

Trim a SpatRaster
depth

depth of SpatRaster layers
diff

Lagged differences
quantile

Quantiles of spatial data
intersect

Intersection
fillTime

Fill time gaps in a SpatRaster
describe

describe
meta

meta
halo

Add halo-ed text to a plot
replace_dollar

Replace with $<-
pairs

Pairs plot (matrix of scatterplots)
freq

Frequency table
subset_dollar

Subset a SpatRaster or a SpatVector
rectify

Rectify a SpatRaster
extract

Extract values from a SpatRaster
summary

summary
elongate

elongate lines
inset

Make an inset map
is.rotated

Check for rotation
scoff

Scale (gain) and offset
global

global statistics
geomtype

Geometry type of a SpatVector
extractAlong

extract values along lines
gdal

GDAL version, supported file formats, and cache size
wrap

wrap and unwrap
headtail

head and tail of a SpatRaster or SpatVector
interpIDW

Interpolate points using a moving window
flip

Flip or reverse a raster
relate

Spatial relationships between geometries
metags

Set or get metadata
factors

Categorical rasters
linearUnits

Linear units of the coordinate reference system
fillHoles

Remove holes from polygons
focal3D

Three-dimensional focal values
mask

Mask values in a SpatRaster or SpatVector
union

Union SpatVector or SpatExtent objects
time

time of SpatRaster layers
plot

Make a map
where

Where are the cells with the min or max values?
is.bool

Raster value types
graticule

Create a graticule
focalMat

Focal weights matrix
regress

Cell level regression
which.lyr

Which cells are TRUE?
forceCCW

force counter-clockwise polygons
makeTiles

Make tiles
summarize

Summarize
mergeTime

merge SpatRasters by timelines to create a single timeseries
match

Value matching for SpatRasters
gridDistance

Distance on a grid
query

Query a SpatVectorProxy object
rotate

Rotate data along longitude
sbar

scale bar
spin

spin a SpatVector
subst

replace cell values
wrapCache

SpatRaster wrap with caching options
initialize

Initialize a SpatRaster with values
interpNear

Nearest neighbor interpolation
sharedPaths

Shared paths
scale

Scale values
add_legend

add a custom legend
inplace

Change values in-place
varnames

variable and long variable names
geom

Get the geometry (coordinates) of a SpatVector
project

Change the coordinate reference system
lines

Add points, lines, or polygons to a map
split

Split
setValues

Set the values of raster cells or of geometry attributes
unique

Unique values
ifel

ifelse for SpatRasters
merge

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

Histogram
units

units of SpatRaster or SpatRasterDataSet
rep

Replicate layers
selectRange

Select the values of a range of layers, as specified by cell values in another SpatRaster
is.empty

Check if a SpatExtent or SpatVector is empty
segregate

segregate
lapp

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

Spatial interpolation
patches

Detect patches (clumps) of cells
map.pal

map.pal arrow
mosaic

mosaic SpatRasters
sel

Spatial selection
update

Change values in a file
not.na

is not NA
panel

Map panel
shift

Shift
Math-methods

General mathematical methods
modal

modal value
rapp

Range-apply
na.omit

Find and remove geometries that are NA
width

SpatVector geometric properties
mem

Memory available and needed
vect

Create SpatVector objects
window

Set a window
origin

Origin
rast

Create a SpatRaster
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
perim

Perimeter or length
same.crs

Compare coordinate reference systems
rcl

Combine row, column, and layer numbers
symdif

Symmetrical difference
zonal

Zonal statistics
plotRGB

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

nearby geometries
predict

Spatial model predictions
zoom

Zoom in on a map
rasterize

Rasterize vector data
replace_layers

Replace layers or variables
viewshed

Compute a viewshed
rangeFill

Fill layers with a range
sds

Create a SpatRasterDataset
persp

Perspective plot
rescale

rescale
options

Options
writeRaster

Write raster data to a file
selectHighest

select cells with high or low values
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
vrt

Virtual Raster Dataset
roll

Rolling (moving) functions
subset

Subset a SpatRaster or a SpatVector
shade

Hill shading
sprc

Create a SpatRasterCollection
stretch

Stretch
plet

Plot with leaflet
tapp

Apply a function to subsets of layers of a SpatRaster
voronoi

Voronoi diagram and Delaunay triangles
subset_double

Subset a SpatRaster or a SpatVector
serialize

saveRDS and serialize for SpatVector and SpatRaster*
writeCDF

Write raster data to a NetCDF file
terra-package

Description of the methods in the terra package
terrain

terrain characteristics
text

Add labels to a map
tmpFiles

Temporary files
readwrite

Read from, or write to, file
vector_layers

List or remove layers from a vector file
xyRowColCell

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

Data sources of a SpatRaster
transpose

Transpose
sort

Sort a SpatRaster or SpatVector
vrt_tiles

filenames of VRT tiles
writeVector

Write SpatVector data to a file
svc

Create a SpatVectorCollection
xmin

Get or set single values of an extent
values

Cell values and geometry attributes
weighted.mean

Weighted mean of layers
NAflag

Set the NA flag
SpatVector-class

Class "SpatVector"