mapme-initiative / mapme.biodiversity

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

worldpop data download error #247

Closed KornTob closed 3 months ago

KornTob commented 3 months ago

Hello, I ran into difficulties downloading worldpop data. The download stopped with the following error message:

Error: Error in purrr::map(seq_along(missing_urls), function(i) { : i In index: 1. Caused by error in download.file(): ! Herunterladen von 'https://data.worldpop.org/GIS/Population/Global_2000_2020/2008/0_Mosaicked/ppp_2008_1km_Aggregated.tif' fehlgeschlagen

My code below:

mp_sf <- gadm(country="IRQ",level=2)

mp_sf <- st_as_sf(mp_sf)

sources <- init_portfolio(st_cast(mp_sf,"POLYGON"), 
                          years = 2010:2023) 

sources <- get_resources(x=sources, resources=c("worldpop"))
goergen95 commented 3 months ago

Hi,

thanks for raising the issue. This is somehow odd, because in your code snippet you specify years = 2010:2023 so we should actually not try to download the data for 2008. Also, when I follow the link printed in the error message I can actually download the file.

When I am running the code below with version 0.5.0, the packages successfully downloads the data for 2010 to 2023 (although it takes a long time). The issue is most likley the latency of the source server, which we really cannot do anything about.

So without further information on errors/warnings from your side my current suggestion is to re-run your code. In case it still fails, try to download the file manually and put it into the right folder (e.g. file.path(outdir, "worldpop"). Sorry, if that is not as helpful as you might have expected...

Also, please note that the worldpop resource we support here is only available for 2000 to 2020.


library(sf)
library(geodata)
library(mapme.biodiversity)

outdir <- tempfile()
dir.create(outdir)

mp_sf <- gadm(country="IRQ",level=2, path = outdir)
mp_sf <- st_as_sf(mp_sf)

sources <- init_portfolio(st_cast(mp_sf,"POLYGON"),
                          years = 2010:2023, outdir = outdir)
sources <- get_resources(x=sources, resources=c("worldpop"))
goergen95 commented 3 months ago

Closing here. Feel free to re-open in case you have some more info to share that would help reproducing the issue.