Conversion for latitude/longitude to altitude in R

user1165199 picture user1165199 · Jan 23, 2012 · Viewed 7.6k times · Source

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 ?

Answer

Spacedman picture Spacedman · Jan 23, 2012

Or you can use the package that looks up from geonames, and get the value from the srtm3 digital elevation model:

First get a geonames username by registering at geonames.org. Then set it:

> options(geonamesUsername="myusernamehere")

then:

> require(geonames)
> GNsrtm3(54.481084,-3.220625)
  srtm3       lng      lat
1   797 -3.220625 54.48108

or the gtopo30 model:

> GNgtopo30(54.481084,-3.220625)
  gtopo30       lng      lat
1     520 -3.220625 54.48108

geonames is on CRAN so install.packages("geonames") will get it.

The difference between these two models is because they are only approximations based on satellite data. Don't go expecting to pinpoint mountains from this.