Learn R Programming

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

terra (version 1.7-39)

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,853

Version

1.7-39

License

GPL (>= 3)

Maintainer

Robert Hijmans

Last Published

June 23rd, 2023

Functions in terra (1.7-39)

add

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

Layers representing colors
activeCat

Active category
SpatRaster-class

SpatRaster class
adjacent

Adjacent cells
aggregate

Aggregate raster or vector data
as.list

Coerce a Spat* object to a list
all.equal

Compare two SpatRasters for equality
as.points

Conversion to a SpatVector of points
atan2

Two argument arc-tangent
autocorrelation

Spatial autocorrelation
align

Align a SpatExtent
animate

Animate a SpatRaster
boxplot

Box plot of SpatRaster data
buffer

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

SpatRaster or SpatVector to data.frame
classify

Classify (or reclassify) cell values
clamp

Clamp values
Arith-methods

Arithmetic
app

Apply a function to the cells of a SpatRaster
approximate

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

Get cell numbers
click

Query by clicking on a map
as.lines

Conversion to a SpatVector of lines
cover

Replace values with values from another object
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
centroids

Centroids
as.polygons

Conversion to a SpatVector of polygons
c

Combine SpatRaster or SpatVector objects
clamp_ts

clamp time series data
cartogram

Cartogram
as.raster

Coerce to a "raster" object
colors

Color table
catalyze

Factors to numeric
cellSize

Area covered by each raster cell
coerce

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

tighten SpatRaster or SpatRasterDataset objects
combineGeoms

Combine geometries
crop

Cut out a geographic subset
deprecated

deprecated methods
Compare-methods

Compare and logical methods
concats

Concatenate categorical rasters
contour

Contour plot
describe

describe
convHull

Convex hull and minimal rotated rectangle
depth

depth of SpatRaster layers
costDist

Cost distance
expanse

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

Create, get or set a SpatExtent
crs

Get or set a coordinate reference system
deepcopy

Deep copy
crosstab

Cross-tabulate
elongate

elongate lines
compareGeom

Compare geometries of SpatRasters
disagg

Disaggregate raster cells or vector geometries
distance

Geographic distance
diff

Lagged differences
erase

Erase parts of a SpatVector object
densify

Add additional nodes to lines or polygons
factors

Categorical rasters
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
density

Density plot
dots

Make a dot-density map
fillTime

Fill time gaps in a SpatRaster
as.character

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

Remove holes from polygons
focal

Focal values
draw

Draw a polygon, line, extent, or points
direction

Direction
focal3D

Three-dimensional focal values
focalCpp

Compute focal values with an iterating C++ function
gaps

Find gaps between polygons
focalMat

Focal weights matrix
barplot

Bar plot of a SpatRaster
flip

Flip or reverse a raster
boundaries

Detect boundaries (edges)
gdal

GDAL version, supported file formats, and cache size
normalize.longitude

normalize vector data that crosses the dateline
focalPairs

Focal function across two layers
focalReg

Focal regression
north

North arrow
headtail

head and tail of a SpatRaster or SpatVector
quantile

Quantiles of spatial data
hist

Histogram
query

Query a SpatVectorProxy object
layerCor

Correlation and (weighted) covariance
add_legend

add a custom legend
inplace

Change values in-place
replace_values

Replace values of a SpatRaster
geom

Get the geometry (coordinates) of a SpatVector
linearUnits

Linear units of the coordinate reference system
inset

Make an inset map
interpIDW

Interpolate points using a moving window
extend

Extend
interpNear

Nearest neighbor interpolation
geomtype

Geometry type of a SpatVector
lines

Add points, lines, or polygons to a map
extract

Extract values from a SpatRaster
persp

Perspective plot
global

global statistics
map.pal

map.pal arrow
ifel

ifelse for SpatRasters
mask

Mask values in a SpatRaster or SpatVector
image

SpatRaster image method
extremes

Get or compute the minimum and maximum cell values
resample

Transfer values of a SpatRaster to another one with a different geometry
is.valid

Check or fix polygon or extent validity
modal

modal value
sds

Create a SpatRasterDataset
plet

Plot with leaflet
patches

Detect patches (clumps) of cells
graticule

Create a graticule
focalValues

Get focal values
lapp

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

segregate
perim

Perimeter or length
freq

Frequency table
rast

Create a SpatRaster
relate

Spatial relationships between geometries
mem

Memory available and needed
names

Names of Spat* objects
merge

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

Make a map
selectHighest

select cells with high or low values
plotRGB

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

Distance on a grid
nearest

nearby geometries
rapp

Range-apply
rangeFill

Fill layers with a range
replace_layers

Replace layers or variables
rasterize

Rasterize vector data
rasterizeGeom

Rasterize geometric properties of vector data
rep

Replicate layers
rasterizeWin

Rasterize points with a moving window
selectRange

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

Sieve filter
initialize

Initialize a SpatRaster with values
is.bool

Raster value types
impose

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

saveRDS and serialize for SpatVector and SpatRaster*
sbar

scale bar
scale

Scale values
summary

summary
simplifyGeom

simplifyGeom geometries
svc

Create a SpatVectorCollection
time

time of SpatRaster layers
symdif

Symmetrical difference
halo

Add halo-ed text to a plot
sort

Sort a SpatRaster or SpatVector
replace_dollar

Replace with $<-
sources

Data sources of a SpatRaster
subst

replace cell values
sel

Spatial selection
tapp

Apply a function to subsets of layers of a SpatRaster
interpolation

Spatial interpolation
intersect

Intersection
summarize

Summarize
terrain

terrain characteristics
text

Add labels to a map
unique

Unique values
is.lonlat

Check for longitude/latitude crs
makeTiles

Make tiles
match

Value matching for SpatRasters
topology

Vector topology methods
makeVRT

Make a VRT header file
mergeTime

merge SpatRasters by timelines to create a single timeseries
transpose

Transpose
vect

Create SpatVector objects
Math-methods

General mathematical methods
writeCDF

Write raster data to a NetCDF file
viewshed

Compute a viewshed
vector_layers

List or remove layers from a vector file
na.omit

na.omit for SpatVector
mosaic

mosaic SpatRasters
meta

meta
not.na

is not NA
origin

Origin
units

units of SpatRaster or SpatRasterDataSet
predict

Spatial model predictions
rotate

Rotate data along longitude
xyRowColCell

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

wrap and unwrap
wrapCache

SpatRaster wrap with caching options
same.crs

Compare coordinate reference systems
pairs

Pairs plot (matrix of scatterplots)
panel

Map panel
zonal

Zonal statistics
update

Change values in a file
plot_extent

Plot a SpatExtent
shift

Shift
sharedPaths

Shared paths
voronoi

Voronoi diagram and Delaunay triangles
plot_graticule

Plot a graticule
tmpFiles

Temporary files
values

Cell values and geometry attributes
width

SpatVector geometric properties
rectify

Rectify a SpatRaster
writeRaster

Write raster data to a file
regress

Cell level regression
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
setValues

Set the values of raster cells or of geometry attributes
project

Change the coordinate reference system
rcl

Combine row, column, and layer numbers
shade

Hill shading
window

Set a window
spin

spin a SpatVector
split

Split
subset_double

Subset a SpatRaster or a SpatVector
terra-package

Description of the methods in the terra package
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
readwrite

Read from, or write to, file
rescale

rescale
options

Options
roll

Rolling (moving) functions
scoff

Scale (gain) and offset
where

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

Scatterplot of two SpatRaster layers
sprc

Create a SpatRasterCollection
which.lyr

Which cells are TRUE?
stretch

Stretch
zoom

Zoom in on a map
subset

Subset a SpatRaster or a SpatVector
vrt

Virtual Raster Dataset
subset_dollar

Subset a SpatRaster or a SpatVector
trim

Trim a SpatRaster
weighted.mean

Weighted mean of layers
union

Union SpatVector or SpatExtent objects
writeVector

Write SpatVector data to a file
xmin

Get or set single values of an extent
SpatExtent-class

Class "SpatExtent"
NAflag

Set the NA flag
SpatVector-class

Class "SpatVector"