Learn R Programming

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

terra (version 1.7-46)

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

196,982

Version

1.7-46

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

September 6th, 2023

Functions in terra (1.7-46)

NAflag

Set the NA flag
align

Align a SpatExtent
adjacent

Adjacent cells
SpatRaster-class

SpatRaster class
activeCat

Active category
RGB

Layers representing colors
SpatExtent-class

Class "SpatExtent"
aggregate

Aggregate raster or vector data
SpatVector-class

Class "SpatVector"
add

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

Coerce a Spat* object to a list
app

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

Conversion to a SpatVector of points
approximate

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

Create a text representation of (the skeleton of) an object
all.equal

Compare two SpatRasters for equality
as.lines

Conversion to a SpatVector of lines
Arith-methods

Arithmetic
animate

Animate a SpatRaster
as.data.frame

SpatRaster or SpatVector to data.frame
buffer

Create a buffer around vector geometries or raster patches
boundaries

Detect boundaries (edges)
autocorrelation

Spatial autocorrelation
c

Combine SpatRaster or SpatVector objects
atan2

Two argument arc-tangent
boxplot

Box plot of SpatRaster data
as.raster

Coerce to a "raster" object
cartogram

Cartogram
coerce

Coercion to vector, matrix or array
click

Query by clicking on a map
clamp_ts

clamp time series data
classify

Classify (or reclassify) cell values
tighten

tighten SpatRaster or SpatRasterDataset objects
barplot

Bar plot of a SpatRaster
catalyze

Factors to numeric
centroids

Centroids
cellSize

Area covered by each raster cell
convHull

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

Clamp values
deprecated

deprecated methods
costDist

Cost distance
as.polygons

Conversion to a SpatVector of polygons
cells

Get cell numbers
concats

Concatenate categorical rasters
depth

depth of SpatRaster layers
colors

Color table
expanse

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

Combine geometries
cover

Replace values with values from another object
Compare-methods

Compare and logical methods
contour

Contour plot
compareGeom

Compare geometries of SpatRasters
ext

Create, get or set a SpatExtent
crs

Get or set a coordinate reference system
densify

Add additional nodes to lines or polygons
elongate

elongate lines
describe

describe
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
flip

Flip or reverse a raster
focal

Focal values
crop

Cut out a geographic subset
crosstab

Cross-tabulate
gdal

GDAL version, supported file formats, and cache size
gaps

Find gaps between polygons
focal3D

Three-dimensional focal values
global

global statistics
graticule

Create a graticule
draw

Draw a polygon, line, extent, or points
diff

Lagged differences
dots

Make a dot-density map
is.rotated

Check for rotation
deepcopy

Deep copy
initialize

Initialize a SpatRaster with values
erase

Erase parts of a SpatVector object
density

Density plot
disagg

Disaggregate raster cells or vector geometries
fillHoles

Remove holes from polygons
is.valid

Check or fix polygon or extent validity
Math-methods

General mathematical methods
freq

Frequency table
interpolation

Spatial interpolation
distance

Geographic distance
focalValues

Get focal values
meta

meta
makeVRT

Make a VRT header file
fillTime

Fill time gaps in a SpatRaster
nearest

nearby geometries
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
extractAlong

extract values along lines
focalReg

Focal regression
factors

Categorical rasters
mergeTime

merge SpatRasters by timelines to create a single timeseries
interpIDW

Interpolate points using a moving window
halo

Add halo-ed text to a plot
plot

Make a map
direction

Direction
forceCCW

force counter-clockwise polygons
extend

Extend
extract

Extract values from a SpatRaster
layerCor

Correlation and (weighted) covariance
focalCpp

Compute focal values with an iterating C++ function
inplace

Change values in-place
ifel

ifelse for SpatRasters
impose

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

Replace values of a SpatRaster
geom

Get the geometry (coordinates) of a SpatVector
focalMat

Focal weights matrix
gridDistance

Distance on a grid
extremes

Get or compute the minimum and maximum cell values
intersect

Intersection
geomtype

Geometry type of a SpatVector
merge

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

Focal function across two layers
patches

Detect patches (clumps) of cells
headtail

head and tail of a SpatRaster or SpatVector
interpNear

Nearest neighbor interpolation
hist

Histogram
mem

Memory available and needed
sharedPaths

Shared paths
makeTiles

Make tiles
is.bool

Raster value types
panel

Map panel
image

SpatRaster image method
lines

Add points, lines, or polygons to a map
add_legend

add a custom legend
north

North arrow
inset

Make an inset map
mosaic

mosaic SpatRasters
rasterize

Rasterize vector data
terrain

terrain characteristics
project

Change the coordinate reference system
map.pal

map.pal arrow
vector_layers

List or remove layers from a vector file
linearUnits

Linear units of the coordinate reference system
is.lonlat

Check for longitude/latitude crs
rcl

Combine row, column, and layer numbers
pairs

Pairs plot (matrix of scatterplots)
xmin

Get or set single values of an extent
plotRGB

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

Mask values in a SpatRaster or SpatVector
match

Value matching for SpatRasters
not.na

is not NA
predict

Spatial model predictions
plet

Plot with leaflet
lapp

Apply a function to layers of a SpatRaster, or sub-datasets of a SpatRasterDataset
same.crs

Compare coordinate reference systems
spin

spin a SpatVector
writeVector

Write SpatVector data to a file
na.omit

Find and remove geometries that are NA
vrt

Virtual Raster Dataset
modal

modal value
subset_double

Subset a SpatRaster or a SpatVector
origin

Origin
scatterplot

Scatterplot of two SpatRaster layers
scoff

Scale (gain) and offset
resample

Transfer values of a SpatRaster to another one with a different geometry
normalize.longitude

normalize vector data that crosses the dateline
names

Names of Spat* objects
selectRange

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

Replicate layers
rectify

Rectify a SpatRaster
units

units of SpatRaster or SpatRasterDataSet
perim

Perimeter or length
roll

Rolling (moving) functions
plot_extent

Plot a SpatExtent
rasterizeWin

Rasterize points with a moving window
readwrite

Read from, or write to, file
plot_graticule

Plot a graticule
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
time

time of SpatRaster layers
rapp

Range-apply
regress

Cell level regression
replace_layers

Replace layers or variables
query

Query a SpatVectorProxy object
symdif

Symmetrical difference
rescale

rescale
persp

Perspective plot
relate

Spatial relationships between geometries
spatSample

Take a regular sample
quantile

Quantiles of spatial data
terra-package

Description of the methods in the terra package
subst

replace cell values
xyRowColCell

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

Fill layers with a range
unique

Unique values
width

SpatVector geometric properties
window

Set a window
stretch

Stretch
selectHighest

select cells with high or low values
values

Cell values and geometry attributes
replace_dollar

Replace with $<-
sbar

scale bar
subset_dollar

Subset a SpatRaster or a SpatVector
summary

summary
serialize

saveRDS and serialize for SpatVector and SpatRaster*
scale

Scale values
viewshed

Compute a viewshed
tapp

Apply a function to subsets of layers of a SpatRaster
subset

Subset a SpatRaster or a SpatVector
summarize

Summarize
setValues

Set the values of raster cells or of geometry attributes
split

Split
sapp

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

Shift
union

Union SpatVector or SpatExtent objects
sds

Create a SpatRasterDataset
zoom

Zoom in on a map
sieve

Sieve filter
wrap

wrap and unwrap
options

Options
svc

Create a SpatVectorCollection
vrt_tiles

filenames of VRT tiles
rast

Create a SpatRaster
vect

Create SpatVector objects
sources

Data sources of a SpatRaster
voronoi

Voronoi diagram and Delaunay triangles
weighted.mean

Weighted mean of layers
zonal

Zonal statistics
sort

Sort a SpatRaster or SpatVector
segregate

segregate
rasterizeGeom

Rasterize geometric properties of vector data
sel

Spatial selection
simplifyGeom

simplifyGeom geometries
shade

Hill shading
text

Add labels to a map
where

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

Transpose
rotate

Rotate data along longitude
trim

Trim a SpatRaster
which.lyr

Which cells are TRUE?
writeCDF

Write raster data to a NetCDF file
sprc

Create a SpatRasterCollection
tmpFiles

Temporary files
writeRaster

Write raster data to a file
update

Change values in a file
topology

Vector topology methods
wrapCache

SpatRaster wrap with caching options