Use R to Bulk-Download Digital Elevation Data with 1" Resolution
[This article was first published on theBioBucket*, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
Here’s a little r-script to convenientely download high quality digital elevation data, i.e. for the Alps, from HERE:Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
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!
To leave a comment for the author, please follow the link and comment on their blog: theBioBucket*.
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.