Learn R Programming

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

terra

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.

Installation

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

Windows

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.

library(devtools)
install.packages("raster")
#devtools::install_github("rspatial/raster")
devtools::install_github("rspatial/terra")

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.

library(devtools)
install.packages("raster")
devtools::install_github("rspatial/terra")

Linux

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.

library(devtools)
install.packages("raster")
devtools::install_github("rspatial/terra")

See the sf instructions for installation on other linux systems.

Copy Link

Version

Install

install.packages('terra')

Monthly Downloads

183,196

Version

0.4-3

License

GPL (>=3)

Issues

Pull Requests

Stars

Forks

Maintainer

Last Published

October 14th, 2024

Functions in terra (0.4-3)

SpatExtent-class

Class "SpatExtent"
initialize

Initialize a SpatRaster with values
focal

Focal values
ifel

ifelse for SpatRaster objects
pairs

Pairs plot (matrix of scatterplots)
pack

pack a Spat* object
compareGeom

Compare geometries of SpatRaster objects
flip

Flip a raster
sampleRegular

Take a regular sample
rotate

Rotate a SpatRaster along longitude
boundaries

Detect boundaries (edges)
subset-vector

Subset of a SpatVector
contour

Contour plot
subset

Subset of a SpatRaster
geomtype

Geometry type of a SpatVector
trim

Trim a SpatRaster
global

global statistics
head and tail

Show the head or tail of a Spat* object
hist

Histogram
unique

Unique values
range

Get or compute the minimum and maximum cell values
modal

modal value
distance

Geographic distance
as.data.frame

Get the attributes of a SpatVector
coerce

Coercion to other object types
collapse

Collapse cell values from a multi-layer SpatRaster
align

Align a SpatExtent with a SpatRaster
select

Geometric subsetting
shift

Shift
draw

Draw a polygon, line, extent, or points
buffer

Create a buffer around vector objects or raster patches
extend

Extend
c

Combine
as.character

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

Create, get or set a SpatExtent
aggregate

Aggregate raster cells
cover

Cover (replace) NA values with values of another raster
isLonLat

Check for longitude/latitude crs
overlay

Overlay SpatRaster objects
interpolate

Interpolate
names

Names of Spat objects
text

Add labels to a map
read and write

Read from, or write to, file
vector-attributes

Get or replace attribute values of a SpatVector
SpatOptions-class

Inspect of set general options for "terra"
crop

Cut out a geographic subset
values

Get cell values
writeVector

Write vector data to a file
tapp

Apply a function to subsets of layers of a SpatRaster
vect

Create SpatVector objects
terra-package

The "terra" package
SpatVector-class

Class "SpatVector"
click

Query by clicking on a map
extract

Extract values from a SpatRaster
adjacent

Adjacent cells
crs

Get or set a coordinate reference system (projection)
density

Density plot
geom

Get the geometry (coordinates) of a SpatVector
classify

Classify (or reclassify) cell values
freq

Frequency table
mask

Mask values in a SpatRaster
predict

Spatial model predictions
math

Mathematical operations with SpatRaster objects
factors

Factors
plotRGB

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

Merge SpatRaster or SpatExtent objects, or a SpatVector with a data.frame
quantile

SpatRaster local quantiles
project

Change the coordinate reference system
persp

Perspective plot
local

Local statistics
plot

Plot a SpatRaster or SpatVector
tmpFiles

Temporary files
rasterize

Rasterize vector data
slope

Compute slopes
rast

Create a SpatRaster
xmin

Get or set single values of an extent
xyRowColCell

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

Data sources of a SpatRaster
warp

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

Transpose
zonal

Zonal statistics
writeRaster

Write raster data to a file
zoom

Zoom in on a map
app

Apply a function to the cells of a SpatRaster
area

Area and perimeter
atan2

Two argument arc-tangent
SpatRaster-class

SpatRaster class
clamp

Clamp values
dimensions

Dimensions of a SpatRaster or SpatVector
SpatDataFrame-class

C++ classes
disaggregate

Disaggregate raster cells
spatSample

Take a regular sample