Skip to contents

getArea reports the area of ecosystem units provided as spatial data

Usage

getArea(x, names_from = NA, ...)

Arguments

x

A SpatRaster, SpatVector, or an sf object with POLYGONS geometry.

names_from

a column names containing ecosystem labels, as a string or dplyr-style column name. Only required for SpatVector and sf types. Units are assumed to be delineated by raster value for SpatRasters.

...

Addition arguments based on input format

Value

A data frame containing ecosystem identifiers and the total area of the ecosystem units in x as a units vector (km^2). For raster bricks it also contains the layer number.

See also

Author

Nicholas Murray murr.nick@gmail.com, Calvin Lee calvinkflee@gmail.com, Aniko B. Toth anikobtoth@gmail.com

Examples

m <- matrix(sample(1:4, 500, replace = TRUE, prob = c(4,1,1,6)), nrow=25, ncol=20)
r1 <- terra::rast(m, crs = "EPSG:32755")
a.r1 <- getArea(r1) # area of all non-NA cells in r1