I'm trying to get SRTM data with "raster
" package in R, but as soon as I'm choosing SRTM
in getData command, I would get the following error:
library(raster)
srtm <- getData('SRTM', lon=16, lat=48)
trying URL 'ftp://xftp.jrc.it/pub/srtmV4/tiff/srtm_40_03.zip'
trying URL 'http://hypersphere.telascience.org/elevation/cgiar_srtm_v4/tiff/zip/srtm_40_03.ZIP'
downloaded 572 bytes
Error in .SRTM(..., download = download, path = path) : file not found
In addition: Warning messages:
1: In utils::download.file(url = aurl, destfile = fn, method = "auto", :
URL 'ftp://xftp.jrc.it/pub/srtmV4/tiff/srtm_40_03.zip': status was 'Couldn't resolve host name'
2: In utils::unzip(zipfilename, exdir = dirname(zipfilename)) :
error 1 in extracting from zip file
Any Idea what is this error for ?
I got all the same errors and I found a solution using
httr
package to download it (source here).I tried BUT THIS DID NOT WORK:
This worked:
I needed to change the raster
.download
function for this. I could make definitive changes withreassignInPackage
fromR.utils
(I think it is definitive) (reassignInPackage(name=".download", pkgName="raster", value="my.fn")
) but I prefer a temporary change.Place this in your code and it will fix the
getData
function:and try again