Examples for 'terra::Summary-methods'


Summarize

Aliases: Summary-methods median mean min max which.min which.max any all prod range sum mean,SpatRaster-method mean,SpatVector-method mean,SpatExtent-method median,SpatRaster-method median,SpatVector-method min,SpatRaster-method max,SpatRaster-method range,SpatRaster-method which.min,SpatRaster-method which.max,SpatRaster-method any,SpatRaster-method all,SpatRaster-method prod,SpatRaster-method range,SpatRaster-method sum,SpatRaster-method stdev stdev,SpatRaster-method

Keywords: methods spatial

### ** Examples

set.seed(0)
r <- rast(nrows=10, ncols=10, nlyrs=3)
values(r) <- runif(ncell(r) * nlyr(r))

x <- mean(r)
# note how this returns one layer
x <- sum(c(r, r[[2]]), 5)

# and this returns three layers
y <- sum(r, r[[2]], 5)

max(r)
class       : SpatRaster 
dimensions  : 10, 10, 1  (nrow, ncol, nlyr)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 
source      : memory 
name        :       max 
min value   : 0.1808664 
max value   : 0.9926841 
max(r, 0.5)
class       : SpatRaster 
dimensions  : 10, 10, 1  (nrow, ncol, nlyr)
resolution  : 36, 18  (x, y)
extent      : -180, 180, -90, 90  (xmin, xmax, ymin, ymax)
coord. ref. : lon/lat WGS 84 
source      : memory 
name        :       max 
min value   :       0.5 
max value   : 0.9926841 
y <- stdev(r)
# not the same as 
yy <- app(r, sd)

z <- stdev(r, r*2)

x <- mean(r, filename=paste0(tempfile(), ".tif"))

[Package terra version 1.5-34 Index]