Does anyone know if there is a tool in R to find the height above sea level of a location, given the latitude and longitude ?
Update: Earthtools no longer exists, so this answer is obsolete. I recommend @Spacedman's answer instead.
As DWin said, there are two parts to this: find a good source of data with a web service, then parse it in R. This answer uses the earthtools.org
service.
library(RCurl)
library(XML)
latitude <- 52.4822
longitude <- -1.8946
url <- paste(
"http://www.earthtools.org/height",
latitude,
longitude,
sep = "/"
)
page <- getURL(url)
ans <- xmlTreeParse(page, useInternalNodes = TRUE)
heightNode <- xpathApply(ans, "//meters")[[1]]
(height <- as.numeric(xmlValue(heightNode)))