rspatial / geodata

download geographic data
GNU General Public License v3.0
147 stars 15 forks source link

Error "download failed" when using `geodata::worldclim_global()` #28

Closed kamaulindhardt closed 1 year ago

kamaulindhardt commented 1 year ago

Download fails when using

file_path <- paste0(dirname(here::here()), "/silvoarable_review/DATASET.FROM.SCRIPT/")

geodata::worldclim_global(var = 'bio', res = 2.5, path = file_path)

Error message:

trying URL 'https://geodata.ucdavis.edu/climate/worldclim/2_1/base/wc2.1_2.5m_bio.zip'
Content type 'application/zip' length 658405521 bytes (627.9 MB)
===========
downloaded 149.5 MB

Warning: downloaded length 156811264 != reported length 658405521Warning: URL 'https://geodata.ucdavis.edu/climate/worldclim/2_1/base/wc2.1_2.5m_bio.zip': Timeout of 60 seconds was reachedError in utils::download.file(url = url, destfile = filename, quiet = quiet,  : 
  download from 'https://geodata.ucdavis.edu/climate/worldclim/2_1/base/wc2.1_2.5m_bio.zip' failed
Error in .downloadDirect(paste0(.wcurl, "base/", zip), pzip, ...) : 
  download failed

However, the old function from the raster package seems to work fine (?):

raster::getData(name = 'worldclim', var = 'bio', res = 2.5, path = file_path)

Warning: getData will be removed in a future version of raster
. Please use the geodata package insteadtrying URL 'https://biogeo.ucdavis.edu/data/climate/worldclim/1_4/grid/cur/bio_2-5m_bil.zip'
Content type 'application/zip' length 129319755 bytes (123.3 MB)
==================================================
downloaded 123.3 MB

class      : RasterStack 
dimensions : 3600, 8640, 31104000, 19  (nrow, ncol, ncell, nlayers)
resolution : 0.04166667, 0.04166667  (x, y)
extent     : -180, 180, -60, 90  (xmin, xmax, ymin, ymax)
crs        : +proj=longlat +datum=WGS84 +no_defs 
names      :  bio1,  bio2,  bio3,  bio4,  bio5,  bio6,  bio7,  bio8,  bio9, bio10, bio11, bio12, bio13, bio14, bio15, ... 
min values :  -278,     9,     8,    64,   -86,  -559,    53,  -278,  -501,  -127,  -506,     0,     0,     0,     0, ... 
max values :   319,   213,    96, 22704,   489,   258,   725,   376,   365,   382,   289, 10577,  2437,   697,   265, ... 
rhijmans commented 1 year ago

That is a download failure because of a timeout. You can set a longer time limit like this

options(timeout = max(900, getOption("timeout")))

(that is done automatically in the development version of geosphere)