How to obtain elevation (sea level) at a placemark?

2,098 views
Skip to first unread message

baffin

unread,
Oct 29, 2008, 2:38:30 PM10/29/08
to KML Developer Support - Google Earth Browser Plugin
I'd like to obtain the elevation with respect to sea level
(ABSOLUTE_ALTITUDE?) at a placemark that is clamped to the ground.
I've tried lots of things but can't get anything other than zero
(probably the altitude wrt ground).

I'm looking for Javascript code to do it, in the environment of the
Plugin.

The GE app obviously can do it -- it displays on the status bar the
elevation of the point on the ground under the mouse pointer.

Any tips?

If it's documented, I'd appreciate the URL (so I can figure out how I
missed it).

Thanks for your help!

barryhunter [KML Guru]

unread,
Oct 29, 2008, 4:04:50 PM10/29/08
to KML Developer Support - Google Earth Browser Plugin
This is probably the URL you are looking for:

http://code.google.com/apis/earth/documentation/reference/interface_g_e_globe.html


That page doesnt seem to show up in a simple search for 'altitude'
using the code.google.com search :(

baffin

unread,
Oct 29, 2008, 4:28:38 PM10/29/08
to KML Developer Support - Google Earth Browser Plugin
Thank you, Barry! That's exactly what I was hoping for!

Here's what I did to try it:

1) Go to http://earth-api-samples.googlecode.com/svn/trunk/demos/interactive/index.html
2) Rotate the globe to put land under the center of view
3) Click 'Create placemark' and 'Run code' (puts a placemark at
center)
4) Replace the code window with this ('placemark' is defined by the
code that runs in step 3):

log(
ge.getGlobe().getGroundAltitude(
placemark.getGeometry().getLatitude(),
placemark.getGeometry().getLongitude()
)
);

and click 'Run code'. This displays the elevation (wrt sea level) at
the placemark in the log output window, as desired.

Thank you!

Tank-

unread,
Nov 6, 2008, 9:55:42 AM11/6/08
to KML Developer Support - Google Earth Browser Plugin
Has anyone else noticed that the getGroundAltitude method performs
inconsistently ? In my case, depending on zoom level I'm at, I will
get different values. Obviously when I'm not zoomed in at all, it
returns zero, but in one case for example, a call to
getGroundAltitude(Lat, Long) returned 99.3774, and when I zoomed out a
little bit, the same call to getGroundAltitude(Lat,Long) returned
96.345 !

Anybody has a fix or explanation for this ? Which is the real value ?

Thanks

On Oct 29, 3:28 pm, baffin wrote:
> Thank you, Barry!  That's exactly what I was hoping for!
>
> Here's what I did to try it:
>
> 1) Go tohttp://earth-api-samples.googlecode.com/svn/trunk/demos/interactive/i...

Roman N

unread,
Nov 7, 2008, 2:48:00 AM11/7/08
to KML Developer Support - Google Earth Browser Plugin
Hi,

This is because terrain altitude data, like most other data in Earth
layers, is regionated. That is, at different zoom levels, different
levels of detail of data for a given latitude/longitude will be
loaded.

Also, getGroundAltitude is intended purely as a visualization helper
method. For example, the Monster Milktruck sample uses it to compute
the milktruck's orientation (heading/tilt/roll, or yaw/pitch/roll) so
that the truck is orthogonal to the terrain surface. getGroundAltitude
isn't designed to provide consistent accurate measurements for storage
or scientific computations.

I will say, though, that the altitude retrieved when zoomed up close
close is likely as accurate as it will get.

Hope that clears things up!

- Roman
Reply all
Reply to author
Forward
0 new messages