global,GRaster-method | R Documentation |
global()
calculates a summary statistic across all the cells of a GRaster
. It returns a single value for each layer of the raster.
## S4 method for signature 'GRaster'
global(x, fun = "mean", probs = seq(0, 1, 0.25), ...)
## S4 method for signature 'missing'
global(x, ...)
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). |
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.
terra::global()
and GRASS module r.univar
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
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.