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 have the same problem, it seems to be a bug. The
getDatafunction inrasterpackage checks for availability of the raster file in three different url's.The first two of them (as of today) are not working or cannot be accessible. However for some reason a small bit data is getting transferred across the server, so the package assumes it to be a available file only to reach an error by
utils. The third url however is most trusted one among the three.I did some digging and came up with the following function after slightly modifying the
rasterpackage itself so that it uses the third url. You can inputLongitudeandLatitudevalues here. Note that this is only useful if you want to download the files based on Latitude & Longitude.Example:
This will result in a file named
srtm_40_03.zipin your folder which would normally contain atif, ahdrand atfwfile of the same name. Use them for further process as usual.EDIT DATE 22-JAN-19: The srtm link as changed (as well), the above code has been adapted to reflect this.