Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

global

global statistics


Description

Compute global statistics, that is summarized values of an entire SpatRaster.

If x is very large global will fail, except when fun is one of "mean", "min", "max", or "sum".

You can compute a weighted mean or sum by providing a SpatRaster with weights.

Usage

## S4 method for signature 'SpatRaster'
global(x, fun="mean", weights=NULL, ...)

Arguments

x

SpatRaster

fun

function to be applied to summarize the values by zone. Either as one of these character values: "max", "min", "mean", "sum", "range", "rms" (root mean square), "sd", "sdpop" (population sd, using n rather than n-1); or, for relatively small SpatRasters, a proper function

...

additional arguments passed on to fun

weights

NULL or SpatRaster

Value

A data.frame with a row for each layer

See Also

zonal for "zonal" statistics, and app or Summary-methods for "local" statistics, and extract for summarizing values for polygons. Also see focal for "focal" or "moving window" operations.

Examples

r <- rast(ncols=10, nrows=10)
values(r) <- 1:ncell(r)
global(r, "sum")
global(r, "mean", na.rm=TRUE)

terra

Spatial Data Analysis

v1.2-10
GPL (>= 3)
Authors
Robert J. Hijmans [cre, aut] (<https://orcid.org/0000-0001-5872-2872>), Roger Bivand [ctb] (<https://orcid.org/0000-0003-2392-6140>), Karl Forner [ctb], Jeroen Ooms [ctb] (<https://orcid.org/0000-0002-4035-0289>), Edzer Pebesma [ctb] (<https://orcid.org/0000-0001-8049-7069>)
Initial release
2021-05-12

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.