Learn R Programming

terra (version 1.8-80)

quantile: Quantiles of spatial data

Description

Compute quantiles for each cell across the layers of a SpatRaster.

You can use use global(x, fun=quantile) to instead compute quantiles across cells for each layer.

You can also use this method to compute quantiles of the numeric variables of a SpatVector.

Usage

# S4 method for SpatRaster
quantile(x, probs=seq(0, 1, 0.25), na.rm=FALSE, filename="", ...) 

# S4 method for SpatVector quantile(x, probs=seq(0, 1, 0.25), ...)

Arguments

Value

SpatRaster with layers representing quantiles

See Also

app

Examples

Run this code
r <- rast(system.file("ex/logo.tif", package="terra"))   
rr <- c(r/2, r, r*2)
qr <- quantile(rr)
qr

if (FALSE) {
# same but slower
qa <- app(rr, quantile)
}

#quantile by layer instead of by cell
qg <- global(r, quantile)

Run the code above in your browser using DataLab