Closed hub-shale closed 2 years ago
Try this to directly download:
utils::download.file(
'https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif',
file.path(dir_env, 'WC_alt_lonlat.tif'))
Or it looks like an issue running MacOS Mojave per Data download error · Issue #14 · lifewatch/sdmpredictors so you'd want to upgrade to Big Sur or similar
Or try to Google similar certificate download issues with MacOS Mojave and see if there's some other workaround to fix the expired security certificates
Trying this:
library(RCurl)
w <- getURL(
'https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif',
.opts=list(followlocation=TRUE, ssl.verifyhost=FALSE, ssl.verifypeer=FALSE))
save
r <- raster('/vsicurl/https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif')
plot(r)
Then trick will be to loop through all layers, like a customized load_layers()
Solution:
Using a suggestion loosely based on https://community.snowflake.com/s/article/Error-Peer-certificate-cannot-be-authenticated-with-given-CA-certificates
Running a bash for loop inside of RStudio works fine, so it seems like the original problem is more limited to the sdmpredictors
package in R.
for item in WC_alt WC_bio1 WC_bio2 ER_tri ER_topoWet
do
curl -v -k https://www.lifewatch.be/sdmpredictors/${item}.tif --output data/${item}.tif
done
Running on Taylor also works (with original code).
When running this line:
I get the error:
trying URL 'https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif' Warning in utils::download.file(layer_url, path, method = "auto", quiet = FALSE, : URL 'https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif': status was 'Peer certificate cannot be authenticated with given CA certificates' Error in utils::download.file(layer_url, path, method = "auto", quiet = FALSE, : cannot open URL 'https://www.lifewatch.be/sdmpredictors/WC_alt_lonlat.tif'
Any suggestions?