Skip to content
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

Closed
fBedecarrats opened this issue Nov 16, 2022 · 2 comments · Fixed by #123
Labels
bug Something isn't working

Comments

@fBedecarrats
Copy link
Collaborator

To compute the treecover_area indicator, the calc_indicators() function takes two arguments: min_cover and min_size.

The problem is the current code for calc_treecover_area.R includes at line 115 :

min_cover <- as.integer(round(min_cover))

This rounds an argument of 0.5 for min_size to 0 and therefore returns NA values for treecover_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:

min_cover <- as.numeric(min_cover)

?

For reference, the FAO forest definition from 2000 is (bold text by me):

Land with tree crown cover (or equivalent stocking level) of more than 10 % and area of more than 0.5 ha. The trees should be able to reach a minimum height of 5 m at maturity in situ. May consist either of closed forest formations where trees of various storeys and undergrowth cover a high proportion of the ground; or open forest formations with a continuous vegetation cover in which tree crown cover exceeds 10 %. Young natural stands and all plantations established for forestry purposes which have yet to reach a crown density of 10 % or tree height of 5 m are included under forest, as are areas normally forming part of the forest area which are temporarily unstocked as a result of human intervention or natural causes but which are expected to revert to forest.

@fBedecarrats
Copy link
Collaborator Author

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)

@goergen95
Copy link
Member

Hi,
so we have the two arguments (for all gfw-related indicators):

#' \item{min_size}{The minimum size of a forest patch to be considered as forest in ha.}
#' \item{min_cover}{The minimum cover percentage per pixel to be considered as forest.}

The gfw_treecover resource is actually encoded as Byte with values ranging from 0 to 100 indicating the percentage of tree cover. So, for the argument min_cover I think it is actually fine to round to an integer value.
However, you are right about the min_size argument, which currently also is set to an integer value here and should be adapted to allow specifying fractions of hectares:

min_size <- as.integer(round(min_size))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants