rowSums: rowSums and colSums for Raster objects

Description Usage Arguments Value See Also Examples

Description

Sum values of Raster objects by row or column.

Usage

1
2
3
4
## S4 method for signature 'Raster'
rowSums(x, na.rm=FALSE, dims=1L,...) 
## S4 method for signature 'Raster'
colSums(x, na.rm=FALSE, dims=1L,...) 

Arguments

x

Raster* object

na.rm

logical. If TRUE, NA values are ignored

dims

this argument is ignored

...

additional arguments (none implemented)

Value

vector (if x is a RasterLayer) or matrix

See Also

See cellStats for summing all cells values

Examples

1
2
3
4
5
r <- raster(ncols=2, nrows=5)
values(r) <- 1:10
as.matrix(r)
rowSums(r)
colSums(r)

Example output

Loading required package: sp
NOTE: rgdal::checkCRSArgs: no proj_defs.dat in PROJ.4 shared files
     [,1] [,2]
[1,]    1    2
[2,]    3    4
[3,]    5    6
[4,]    7    8
[5,]    9   10
[1]  3  7 11 15 19
[1] 25 30

raster documentation built on Jan. 5, 2021, 3:01 a.m.