quantile function

Quantiles of spatial data

Quantiles of spatial data

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. methods

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

Arguments

  • x: SpatRaster or SpatVector
  • probs: numeric vector of probabilities with values in [0,1]
  • na.rm: logical. If TRUE, NA's are removed from x before the quantiles are computed
  • filename: character. Output filename
  • ...: additional arguments for writing files as in writeRaster

Returns

SpatRaster with layers representing quantiles

See Also

app

Examples

r <- rast(system.file("ex/logo.tif", package="terra")) rr <- c(r/2, r, r*2) qr <- quantile(rr) qr ## Not run: # same but slower qa <- app(rr, quantile) ## End(Not run) #quantile by layer instead of by cell qg <- global(r, quantile)
  • Maintainer: Robert J. Hijmans
  • License: GPL (>= 3)
  • Last published: 2025-02-26