-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Impossible to compute treecover_area indicator with min_size corresponding to FAO forest definition (0.5) #110
Comments
I forgot to include a reproducible example. Here it is: # Install the latest versions + updated dependencies
remotes::install_github("mapme-initiative/mapme.biodiversity",
upgrade = "always")
install.packages("wdpar")
library(dplyr)
library(sf)
library(mapme.biodiversity)
library(wdpar)
# Downloading Protected areas from Madagascar
PA_mada <- wdpa_fetch("Madagascar", wait = TRUE)
PA_test <- PA_mada %>%
filter(NAME == "Ambatovaky")
# Discard points and cast multipolygons as polygons
PA_poly <- PA_test %>%
filter(st_geometry_type(.) == "MULTIPOLYGON") %>%
st_cast("POLYGON")
# Create portfolio
PA_poly <- init_portfolio(x = PA_poly,
years = 2000:2020,
outdir = "data_test",
cores = 8,
add_resources = TRUE,
verbose = TRUE)
# Get GFW data
PA_poly <- get_resources(x = PA_poly,
resources = c("gfw_treecover", "gfw_lossyear"))
# Compute indicators : works with min_size = 1
PA_poly <- calc_indicators(x = PA_poly,
indicators = "treecover_area",
min_cover = 10, min_size = 1)
# Compute indicators : doesn't works with min_size = 0.5
PA_poly <- calc_indicators(x = PA_poly,
indicators = "treecover_area",
min_cover = 10, min_size = 0.5) |
Hi, mapme.biodiversity/R/calc_treecover_area.R Lines 13 to 14 in 71065ae
The mapme.biodiversity/R/calc_treecover_area.R Line 128 in 71065ae
|
To compute the
treecover_area
indicator, thecalc_indicators()
function takes two arguments:min_cover
andmin_size
.The problem is the current code for calc_treecover_area.R includes at line 115 :
This rounds an argument of 0.5 for
min_size
to 0 and therefore returns NA values fortreecover_area
.There are cases when this value needs to be a fraction, for instance to reflect the FAO definition for forests (see below). Would it be possible to simply remove the line above, or remplace it with:
?
For reference, the FAO forest definition from 2000 is (bold text by me):
The text was updated successfully, but these errors were encountered: