mapme-initiative / mapme.biodiversity

Efficient analysis of spatial biodiversity datasets for global portfolios
https://mapme-initiative.github.io/mapme.biodiversity/dev
GNU General Public License v3.0
33 stars 7 forks source link

GMW Data conversion fails due to incorrect file name #80

Closed karpfen closed 2 years ago

karpfen commented 2 years ago

When downloading GMW data, the package first downloads a zipped ShapeFile and then converts it to GeoPackage. However, for the conversion, it tries to use a non-existent file and the path has to be adapted manually.

Here's a reproducible example (tried in Windows 10, R 4.1.2, mapme.biodiversity version 0.1.1)

library(mapme.biodiversity)
library(sf)
poly_test <- st_polygon(
   list(
      cbind(
         c(174.4313, 174.4313, 174.432, 174.432, 174.4313),
         c(-36.27457, -36.27408, -36.27408, -36.27457, -36.27457)
      )
   )
)
poly_test <- st_sf(st_sfc(poly_test, crs = 4326))
mangrove <- poly_test %>%
   init_portfolio(2016,
                  verbose = TRUE) %>%
   get_resources(
     resources = c("mangrove")
   )

For me, this produces the following messages:

Starting process to download resource 'mangrove'........ Checking URLs for existence. This may take a while... |++++++++++++++++++++++++++++++++++++++++++++++++++| 100% elapsed=32s
Translating shapefiles to GeoPackages. This may take a while.... <Rcpp::exception: Cannot open "C:/path/to/script/mangrove/GMW_001_GlobalMangroveWatch_2016/01_Data/GMW_2016_v2.shp"; The file doesn't seem to exist.>

Warning messages: 1: In init_portfolio(., 2016, verbose = TRUE) : Parallel processing on Windows currently is not supported. Setting number of cores to 1 2: Download for resource mangrove failed. Returning unmodified portfolio object.

Only after creating the script from the error message and moving the ShapeFile there, the GeoPackage can be produced.

goergen95 commented 2 years ago

Thanks for reporting this issue. First of all, please consider updating mapme.biodiversity. Current CRAN release is 0.1.2, development version is 0.2.0. Please note that with 0.2.0 a lot of resources and indicators have been renamed so it is better to move to that version rather now than later. However, this will not fix the above mentioned issue. I did a little digging, and It seems that a new v3 of GMW was released recently. I will push an update here on GitHub very soon and hopefully we can also send it to CRAN during the next release.

goergen95 commented 2 years ago

please install the latest development version via: remotes::install_github("mapme-initiative/mapme.biodiversity") and feel free to re-open if the issue persists.

karpfen commented 2 years ago

Thanks for the quick response! I just tried it in the dev version and it works as expected now.