Learn R Programming

terra (version 1.8-80)

extractRange: Extract values for a range of layers from a SpatRaster

Description

Extract values from a SpatRaster for a set of locations and a range of layers. To extract values for a single or all layers, use extract

Usage

# S4 method for SpatRaster
extractRange(x, y, first, last, lyr_fun=NULL, 
		geom_fun=NULL, ID=FALSE, na.rm=TRUE, bind=FALSE, ...)

Arguments

Value

numeric or data.frame

See Also

extract

Examples

Run this code
r <- rast(system.file("ex/logo.tif", package="terra"))   
xy <- data.frame(lon=c(50,80), lat=c(30, 60))
extract(r, xy)
extract(r, xy, layer=c("red", "green"))

extractRange(r, xy, first=1:2, last=3:2)
extractRange(r, xy, first=1:2, last=3:2, lyr_fun=sum)

Run the code above in your browser using DataLab