rowSums: row/col sums and means for SpatRaster

rowSumsR Documentation

row/col sums and means for SpatRaster

Description

Sum or average values of SpatRaster layers by row or column.

Usage

## S4 method for signature 'SpatRaster'
rowSums(x, na.rm=FALSE, dims=1L, ...) 
## S4 method for signature 'SpatRaster'
colSums(x, na.rm=FALSE, dims=1L, ...) 
## S4 method for signature 'SpatRaster'
rowMeans(x, na.rm=FALSE, dims=1L, ...) 
## S4 method for signature 'SpatRaster'
colMeans(x, na.rm=FALSE, dims=1L, ...) 

Arguments

x

SpatRaster

na.rm

logical. If TRUE, NA values are ignored

dims

this argument is ignored

...

additional arguments (none implemented)

Value

matrix

See Also

See global for summing all cells values

Examples

r <- rast(ncols=2, nrows=5, nl=2, vals=1:20)
rowSums(r)
colSums(r)
colMeans(r)

rspatial/terra documentation built on Jan. 7, 2025, 6:27 p.m.