Learn R Programming

terra (version 0.2-9)

local: Local statistics

Description

Compute cell (pixel) level "local" statistics across layers, and most return a single layer (the exception is range).

The following summary methods are available for SpatRaster: mean, max, min, range, prod, sum, any, all

See reduce to compute statistics that are not included here (e.g. median) or any other custom functions.

Because generic functions are used, the method applied is chosen based on the first argument: 'x'. This means that if r is a SpatRaster, mean(r, 5) will work, but mean(5, r) will not work.

To summarize the values of all cells by layer see layerStats.

Arguments

Value

SpatRaster

See Also

Math-methods

Examples

Run this code
# NOT RUN {
set.seed(0)
r <- rast(nrow=10, ncol=10, nlyr=3)
values(r) <- runif(size(r))

x <- mean(r)
x <- sum(r, r[[2]], 3)
max(r)
max(r, 0.5)
# }

Run the code above in your browser using DataLab