
Calculate treeloss statistics
Source:R/calc_treecover_area_and_emissions.R
treecover_area_and_emissions.Rd
This functions allows to efficiently calculate the treecover and emissions indicators in a single function call together. Since most of the pre-processing operations for treecover and emissions are the same, it is more efficient to calculate them in one run if users are actually interested in both statistics. Otherwise users are advised to use the respective single indicator functions. The required resources for this indicator are:
Details
The following arguments can be set:
- min_size
The minimum size of a forest patch to be considered as forest in ha.
- min_cover
The minimum cover percentage per pixel to be considered as forest.
Examples
if (Sys.getenv("NOT_CRAN") == "true") {
library(sf)
library(mapme.biodiversity)
temp_loc <- file.path(tempdir(), "mapme.biodiversity")
if (!file.exists(temp_loc)) {
dir.create(temp_loc)
resource_dir <- system.file("res", package = "mapme.biodiversity")
file.copy(resource_dir, temp_loc, recursive = TRUE)
}
(try(aoi <- system.file("extdata", "sierra_de_neiba_478140_2.gpkg",
package = "mapme.biodiversity"
) %>%
read_sf() %>%
init_portfolio(
years = 2016:2017,
outdir = file.path(temp_loc, "res"),
tmpdir = tempdir(),
add_resources = FALSE,
verbose = FALSE
) %>%
get_resources(
resources = c("gfw_treecover", "gfw_lossyear", "gfw_emissions"),
vers_treecover = "GFC-2021-v1.9", vers_lossyear = "GFC-2021-v1.9"
) %>%
calc_indicators("treecover_area_and_emissions", min_size = 1, min_cover = 30) %>%
tidyr::unnest(treecover_area_and_emissions)))
}
#> Simple feature collection with 2 features and 8 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -71.80933 ymin: 18.57668 xmax: -71.33201 ymax: 18.69931
#> Geodetic CRS: WGS 84
#> # A tibble: 2 × 9
#> WDPAID NAME DESIG_ENG ISO3 assetid years emissions treecover
#> <dbl> <chr> <chr> <chr> <int> <int> <dbl> <dbl>
#> 1 478140 Sierra de Neiba National Park DOM 1 2016 2832. 12011.
#> 2 478140 Sierra de Neiba National Park DOM 1 2017 3468. 11939.
#> # ℹ 1 more variable: geom <POLYGON [°]>