calc-RasterArray-function-method: Calculate method for the RasterArray object

Description Usage Arguments Details Value Examples

Description

Calculate values for a new RasterLayer/RasterArray object from another RasterArray object, using a formula.

Usage

1
2
## S4 method for signature 'RasterArray,'function''
calc(x, fun, margin = NULL, na.rm = NULL, forcefun = FALSE, forceapply = FALSE)

Arguments

x

A RasterArray class object.

fun

function to be applied.

margin

The MARGIN parameter of the apply function. If set to NULL then the fun will be applied to the entire stack, producing a single layer.

na.rm

Remove NA values, if supported by 'fun' (only relevant when summarizing a multilayer Raster object into a RasterLayer)

forcefun

logical. Force calc to not use fun with apply; for use with ambiguous functions and for debugging (see Details)

forceapply

logical. Force calc to use fun with apply; for use with ambiguous functions and for debugging (see Details)

Details

The method is an extension of the calc function. The strucuture expressed as the RasterArray's dimensions allows the calculations to be iterated for different margins of the array, similarly to the apply function, controlled by the margin argument.

Value

A RasterLayer or RasterArray class object.

Examples

1
2
3
4
data(dems)

d2 <- cbind(dems, dems)
double <- calc(d2, margin=1, fun=sum)

chronosphere documentation built on April 19, 2021, 1:07 a.m.