Skip to contents

Area calculation

Usage

area.calc(r1, unit = "km", r2 = NULL, r3 = NULL, filename = "")

Arguments

r1

A SpatRaster or a list of multiple SpatRasters.

unit

Character. Default is "km", but "m" and "ha" are also available.

r2

A SpatRaster with the same resolution and extent as "r1".

r3

A SpatRaster with the same resolution and extent as "r1".

filename

Character. Save results if a name is provided.

Value

A vector or a data.frame with area values in the chosen unit.

Examples

# \donttest{
library(terra)
#> terra 1.7.78
bin1 <- terra::rast(system.file("extdata", "ref.tif",
package = "divraster"))
my.list <- list(bin1 = bin1[[1:2]])
area.calc(my.list)
#>   sp scenario total.area
#> 1  A     bin1   6154.240
#> 2  B     bin1   6346.524
# }