Skip to content
Prev 4571 / 29559 Next

Geonames elevation help

2008/11/25 Michael Denslow <mwdenslow at yahoo.com>:
Maybe you were using apply wrong.

 With your df, you can do:

 > df$srtm3=apply(df,1,function(l){GNsrtm3(l[1],l[2])$srtm3})
 > df
     lat   long srtm3
 1 36.21 -81.66   990
 2 37.21 -82.66   500

 apply() passes the row of the dataframe as a vector to the function,
so I just get the first and last element and call GNsrtm3, and strip
off just the result.

 Oh, make sure I've got the lat-long the right way round.

Barry