total-methods: Total number of cells in a Raster* object

Description Usage Arguments Details Value Examples

Description

Count the area or number of cells belonging to each category in a Raster* object.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
total(x, ...)

## S4 method for signature 'DiscreteLulcRasterStack'
total(x, categories, ...)

## S4 method for signature 'ContinuousLulcRasterStack'
total(x, categories, ...)

## S4 method for signature 'Raster'
total(x, categories, ...)

Arguments

x

Raster* object

...

additional arguments (none)

categories

numeric vector containing land use categories. Only cells belonging to these categories will be counted

Details

If x is a DiscreteLulcRasterStack object this function returns the number of cells belonging to each category. If x is a ContinuousLulcRasterStack object the function returns the sum of the fractions of the various land use categories.

Value

A list containing the following components:

total

a matrix containing the total number of cells belonging to each category. Rows represent layers in the input Raster* object

categories

the categories included in the calculation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Sibuyan Island

lu <- DiscreteLulcRasterStack(x=stack(sibuyan$maps[1:2]),
                              categories=c(1,2,3,4,5),
                              labels=c("forest","coconut","grass","rice","other"),
                              t=c(0,14))

total(x=lu)
total(x=lu[[1]])
total(x=lu[[2]])

simonmoulds/lulcc2 documentation built on Dec. 23, 2021, 2:24 a.m.