global,GRaster-method {fasterRaster} | R Documentation |
Summary statistics for GRasters
Description
global()
calculates a summary statistic across all the cells of a GRaster
. It returns a single value for each layer of the raster.
Usage
## S4 method for signature 'GRaster'
global(x, fun = "mean", probs = seq(0, 1, 0.25), ...)
## S4 method for signature 'missing'
global(x, ...)
Arguments
x |
A |
fun |
Character vector: The name of the function(s):
|
probs |
Numeric within the range from 0 to 1: Quantile(s) at which to calculate |
... |
Other arguments (unused). |
Value
If x
is missing, the function returns a character vector of all accepted function names. If x
is a GRaster
, a data frame with the specified statistics is returned.
See Also
terra::global()
and GRASS tool r.univar
Examples
if (grassStarted()) {
# Setup
library(terra)
# Example data
madElev <- fastData("madElev")
# Convert a SpatRaster to a GRaster:
elev <- fast(madElev)
# What functions can we use with global()?
global()
# Calculate global statistics:
global(elev, fun = c("mean", "var", "varpop"))
global(elev, "quantile", probs = c(0.25, 0.5, 0.75))
global(elev, "*") # calculate all available functions
}