require(XML)
dir.create("D:/GIS_DataBase/DEM/")
setwd("D:/GIS_DataBase/DEM/")
doc <- htmlParse("http://www.viewfinderpanoramas.org/dem3.html#alps")
urls <- paste0("http://www.viewfinderpanoramas.org", xpathSApply(doc,'//*/a[contains(@href,"/dem1/N4")]/@href'))
names <- gsub(".*dem1/(\\w+\\.zip)", "\\1", urls)
for (i in 1:length(urls)) download.file(urls[i], names[i])
# unzip all files in dir and delete them afterwards
sapply(list.files(pattern = "*.zip"), unzip)
unlink(list.files(pattern = "*.zip"))
p.s.: Also check raster::getData which pulls SRTM data at 90m resolution for a location / region!
how do you get R to read the *.hgt files?
ReplyDeleteit is not read, only downloaded..
DeleteI have not been able to run the code, the end of the script I get this Error
ReplyDeleteFile NA done! ..
..something happend with NA dataset:
Error in .local (.Object, ...): 'Q: \ Geodatabase \ DEM \ NA.tif' does not exist in the file system,
and is not Recognised as a supported dataset name.
Sorry Alvaro, I can't reproduce your error - for me everything's working fine...
Delete