ropensci / rnaturalearth

An R package to hold and facilitate interaction with natural earth map data :earth_africa:
http://ropensci.github.io/rnaturalearth/
Other
214 stars 24 forks source link

`ne_download()` fails to read raster objects #96

Closed eliocamp closed 7 months ago

eliocamp commented 7 months ago

Reprex:

rast <- rnaturalearth::ne_download(category = "raster", type = "HYP_50M_SR_W", scale = 50)
#> Warning: The `returnclass` argument of `ne_download()` sp as of rnaturalearth 1.0.0.
#> ℹ Please use `sf` objects with {rnaturalearth}, support for Spatial objects
#>   (sp) will be removed in a future release of the package.
#> This warning is displayed once every 8 hours.
#> Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
#> generated.
#> Warning: /tmp/RtmpV6NNlD/HYP_50M_SR_W/HYP_50M_SR_W.tif: No such file or
#> directory (GDAL error 4)
#> Error: [rast] file does not exist: /tmp/RtmpV6NNlD/HYP_50M_SR_W/HYP_50M_SR_W.tif

Created on 2023-11-21 with reprex v2.0.2

The problem is that HYP_50M_SR_W.tif is not in the HYP_50M_SR_W subdir. This

https://github.com/ropensci/rnaturalearth/blob/704772792ecafb0f29b9f68089fdab80ccf4cb43/R/ne_download.R#L138

Might need to be

 rst <- terra::rast(file.path(destdir, paste0(file_name, ".tif"))) 
eliocamp commented 7 months ago

Sorry, I've just noticed that this is addressed in #52

PMassicotte commented 7 months ago

Thank you, just fixed it in the dev version.