Learn R Programming

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

terra (version 1.7-29)

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

License

GPL (>= 3)

Maintainer

Last Published

April 22nd, 2023

Functions in terra (1.7-29)

SpatRaster-class

SpatRaster class
NAflag

Set the NA flag
align

Align a SpatExtent
SpatExtent-class

Class "SpatExtent"
RGB

Layers representing colors
as.data.frame

SpatRaster or SpatVector to data.frame
all.equal

Compare two SpatRasters for equality
Arith-methods

Arithmetic
as.raster

Coerce to a "raster" object
animate

Animate a SpatRaster
as.spatvector

Conversion to a SpatVector, or to another SpatVector type
as.character

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

Bar plot of a SpatRaster
as.list

Coerce a Spat* object to a list
boxplot

Box plot of SpatRaster data
catalyze

Factors to numeric
boundaries

Detect boundaries (edges)
c

Combine SpatRaster or SpatVector objects
cellSize

Area covered by each raster cell
centroids

Centroids
cells

Get cell numbers
colors

Color table
combineGeoms

Combine geometries
cartogram

Cartogram
clamp

Clamp values
clamp_ts

clamp time series data
crop

Cut out a geographic subset
app

Apply a function to the cells of a SpatRaster
crosstab

Cross-tabulate
concats

Concatenate categorical rasters
densify

Add additional nodes to lines or polygons
crs

Get or set a coordinate reference system
contour

Contour plot
approximate

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

Convex hull and minimal rotated rectangle
atan2

Two argument arc-tangent
crds

Get the coordinates of SpatVector geometries or SpatRaster cells
deepcopy

Deep copy
buffer

Create a buffer around vector geometries or raster patches
density

Density plot
extend

Extend
deprecated

deprecated methods
extract

Extract values from a SpatRaster
autocorrelation

Spatial autocorrelation
depth

depth of SpatRaster layers
expanse

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

Focal function across two layers
focalReg

Focal regression
coerce

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

elongate lines
tighten

tighten SpatRaster or SpatRasterDataset objects
erase

Erase parts of a SpatVector object
global

global statistics
ext

Create, get or set a SpatExtent
classify

Classify (or reclassify) cell values
graticule

Create a graticule
click

Query by clicking on a map
factors

Categorical rasters
compareGeom

Compare geometries of SpatRasters
Compare-methods

Compare and logical methods
fillHoles

Remove holes from polygons
ifel

ifelse for SpatRasters
focalValues

Get focal values
focalCpp

Compute focal values with an iterating C++ function
image

SpatRaster image method
focalMat

Focal weights matrix
is.bool

Raster value types
describe

describe
is.lonlat

Check for longitude/latitude crs
mem

Memory available and needed
costDist

Cost distance
merge

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

Names of Spat* objects
freq

Frequency table
cover

Replace values with values from another object
nearest

nearby geometries
pairs

Pairs plot (matrix of scatterplots)
interpIDW

Interpolate points using a moving window
interpNear

Nearest neighbor interpolation
dimensions

Dimensions of a SpatRaster or SpatVector and related objects
direction

Direction
interpolation

Spatial interpolation
intersect

Intersection
diff

Lagged differences
gaps

Find gaps between polygons
panel

Map panel
mergeTime

merge SpatRasters by timelines to create a single timeseries
gdal

GDAL version, supported file formats, and cache size
disagg

Disaggregate raster cells or vector geometries
meta

meta
dots

Make a dot-density map
draw

Draw a polygon, line, extent, or points
rangeFill

Fill layers with a range
distance

Geographic distance
not.na

is not NA
headtail

head and tail of a SpatRaster or SpatVector
hist

Histogram
rapp

Range-apply
focal

Focal values
origin

Origin
valid

Check or fix polygon or extent validity
fillTime

Fill time gaps in a SpatRaster
lapp

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

Replicate layers
makeTiles

Make tiles
relate

Spatial relationships between geometries
plot_extent

Plot a SpatExtent
flip

Flip or reverse a raster
geom

Get the geometry (coordinates) of a SpatVector
focal3D

Three-dimensional focal values
gridDistance

Distance on a grid
plot_graticule

Plot a graticule
geomtype

Geometry type of a SpatVector
quantile

Quantiles of spatial data
halo

Add halo-ed text to a plot
query

Query a SpatVectorProxy object
spatSample

Take a regular sample
inplace

Change values in-place
sapp

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

Make a VRT header file
impose

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

Initialize a SpatRaster with values
extremes

Get or compute the minimum and maximum cell values
rcl

Combine row, column, and layer numbers
modal

modal value
patches

Detect patches (clumps) of cells
linearUnits

Linear units of the coordinate reference system
readwrite

Read from, or write to, file
perim

Perimeter or length
rasterizeGeom

Rasterize geometric properties of vector data
lines

Add points, lines, or polygons to a map
inset

Make an inset map
rescale

rescale
layerCor

Correlation and (weighted) covariance
rasterizeWin

Rasterize points with a moving window
sharedPaths

Shared paths
match

Value matching for SpatRasters
shift

Shift
roll

Rolling (moving) functions
Math-methods

General mathematical methods
subset

Subset a SpatRaster or a SpatVector
replace_values

Replace values of a SpatRaster
mosaic

mosaic SpatRasters
subset_dollar

Subset a SpatRaster or a SpatVector
add_legend

add a custom legend
map.pal

map.pal arrow
resample

Transfer values of a SpatRaster to another one with a different geometry
na.omit

na.omit for SpatVector
plot

Make a map
mask

Mask values in a SpatRaster or SpatVector
normalize.longitude

normalize vector data that crosses the dateline
scatterplot

Scatterplot of two SpatRaster layers
plotRGB

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

Create a SpatRaster
north

North arrow
scoff

Scale (gain) and offset
persp

Perspective plot
rasterize

Rasterize vector data
plet

Plot with leaflet
rectify

Rectify a SpatRaster
regress

Cell level regression
sel

Spatial selection
symdif

Symmetrical difference
tapp

Apply a function to subsets of layers of a SpatRaster
sbar

scale bar
predict

Spatial model predictions
topology

Vector topology methods
scale

Scale values
project

Change the coordinate reference system
replace_dollar

Replace with $<-
transpose

Transpose
selectRange

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

Replace layers or variables
serialize

serialize and saveRDS for SpatRaster and SpatVector
selectHighest

select cells with high or low values
sort

Sort a SpatRaster or SpatVector
sources

Data sources of a SpatRaster
sprc

Create a SpatRasterCollection
vect

Create SpatVector objects
stretch

Stretch
vector_layers

List or remove layers from a vector file
setValues

Set the values of raster cells or of geometry attributes
rotate

Rotate data along longitude
wrap

wrap and unwrap
writeCDF

Write raster data to a NetCDF file
shade

Hill shading
same.crs

Compare coordinate reference systems
spin

spin a SpatVector
split

Split
terra-package

Description of the methods in the terra package
sds

Create a SpatRasterDataset
segregate

segregate
options

Options
sieve

Sieve filter
unique

Unique values
simplifyGeom

simplifyGeom geometries
summary

summary
svc

Create a SpatVectorCollection
subst

replace cell values
units

units of SpatRaster or SpatRasterDataSet
summarize

Summarize
where

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

terrain characteristics
text

Add labels to a map
which.lyr

Which cells are TRUE?
writeRaster

Write raster data to a file
writeVector

Write SpatVector data to a file
update

Change values in a file
subset_double

Subset a SpatRaster or a SpatVector
time

time of SpatRaster layers
subset_single

Extract values from a SpatRaster, SpatVector or SpatExtent
tmpFiles

Temporary files
values

Cell values and geometry attributes
xmin

Get or set single values of an extent
xyRowColCell

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

Trim a SpatRaster
union

Union SpatVector or SpatExtent objects
vrt

Virtual Raster Dataset
weighted.mean

Weighted mean of layers
zonal

Zonal statistics
zoom

Zoom in on a map
viewshed

Compute a viewshed
voronoi

Voronoi diagram and Delaunay triangles
width

SpatVector geometric properties
window

Set a window
SpatVector-class

Class "SpatVector"
activeCat

Active category
aggregate

Aggregate raster or vector data
adjacent

Adjacent cells
add

Add (in place) a SpatRaster to another SpatRaster object