terra v0.3-7

Classes and Methods for Spatial Data

Classes and methods for spatial data.



Travis build

This R package is a replacement of the raster package. It has a very similar, but simpler, interface, and it is much faster.

All native computations are done in C++. Classes, methods and properties are exposed via a Rcpp module. The R side has two main S4 classes (SpatRaster and SpatVector) that represent spatial data. These classes have only slot, a reference to a C++ object. They are used to provide a "normal" "S4" R user-interface as in the raster package.

The first (alpha) release is expected by July 2019.


You need to install the latest version of "raster" from CRAN or github.


If you are on Windows, you need to first install Rtools to get a C++ compiler that R can use. After that, you need the first install development version of "raster" for "terra" to work.

Then, in R, install the packages.


Mac - OSX

The libraries GDAL (>= 2.0.0), GEOS (>= 3.3.0) and Proj.4 (>= 4.8.0) are required (as for sf)

With Homebrew you can do:

brew install gdal

And now, in R, install the packages.



The libraries GDAL (>= 2.0.0), GEOS (>= 3.3.0) and Proj.4 (>= 4.8.0) are required (as for sf)

To install these on Ubuntu you can do:

sudo add-apt-repository ppa:ubuntugis/ubuntugis-unstable
sudo apt-get update
sudo apt-get install libgdal-dev libgeos-dev libproj-dev

And now, in R, install the packages.


See the sf instructions for installation on other linux systems.

Functions in terra

Name Description
buffer Create a buffer around vector objects or raster patches
compareGeom Compare geometries of SpatRaster objects
collapse Collapse cell values from a multi-layer SpatRaster
area Area and perimeter
app Apply a function to the cells of a SpatRaster
SpatExtent-class Class "SpatExtent"
crop Cut out a geographic subset
dimensions Dimensions of a SpatRaster or SpatVector
geom Get the geometry (coordinates) of a SpatVector
crs Get or set a coordinate reference system (projection)
focal Focal values
as.data.frame Get the attributes of a SpatVector
atan2 Two argument arc-tangent
geomtype Geometry type of a SpatVector
freq Frequency table
adjacent Adjacent cells
SpatDataFrame-class C++ classes
SpatRaster-class SpatRaster class
classify Classify (or reclassify) cell values
draw Draw a polygon, line, extent, or points
factors Factors
extend Extend
hist Histogram
mask Mask values in a SpatRaster
global global statistics
disaggregate Disaggregate raster cells
flip Flip a raster
shift Shift
select Geometric subsetting
math Mathematical operations with SpatRaster objects
predict Spatial model predictions
plotRGB Red-Green-Blue plot of a multi-layered SpatRaster
tapp Apply a function to subsets of layers of a SpatRaster
initialize Initialize a SpatRaster with values
interpolate Interpolate
head and tail Show the head or tail of a Spat* object
ifel ifelse for SpatRaster objects
overlay Overlay SpatRaster objects
clamp Clamp values
cover Cover (replace) NA values with values of another raster
c Combine
contour Contour plot
terra-package The "terra" package
isLonLat Check for longitude/latitude crs
xmin Get or set single values of an extent
modal modal value
local Local statistics
persp Perspective plot
plot Plot a SpatRaster or SpatVector
read and write Read from, or write to, file
xyRowColCell Coordinates from a row, column or cell number and vice versa
tmpFiles Temporary files
transpose Transpose
vector-attributes Get or replace attribute values of a SpatVector
rast Create a SpatRaster
SpatOptions-class Inspect of set general options for "terra"
rasterize Rasterize vector data
warp Transfer values of a SpatRaster to another one with a different geometry
text Add labels to a map
pairs Pairs plot (matrix of scatterplots)
project Change the coordinate reference system
quantile SpatRaster local quantiles
writeRaster Write raster data to a file
names Names of Spat objects
rotate Rotate a SpatRaster along longitude
subset-vector Subset of a SpatVector
zonal Zonal statistics
zoom Zoom in on a map
sampleRegular Take a regular sample
subset Subset of a SpatRaster
trim Trim a SpatRaster
distance Geographic distance
unique Unique values
values Get cell values
extract Extract values from a SpatRaster
merge Merge SpatRaster or SpatExtent objects, or a SpatVector with a data.frame
extent Create, get or set a SpatExtent
vect Create SpatVector objects
slope Compute slopes
range Get or compute the minimum and maximum cell values
sources Data sources of a SpatRaster
click Query by clicking on a map
coerce Coercion to other object types
SpatVector-class Class "SpatVector"
aggregate Aggregate raster cells
align Align a SpatExtent with a SpatRaster
boundaries Detect boundaries (edges)
density Density plot
No Results!


Type Package
Date 2019-09-21
LinkingTo Rcpp
SystemRequirements C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= 4.8.0)
License GPL (>=3)
URL https://github.com/rspatial/terra
BugReports https://github.com/rspatial/raster/issues/
LazyLoad yes

Include our badge in your README