Unexpected getGroundAltitude() Behavior

58 views
Skip to first unread message

DougH

unread,
Sep 25, 2009, 1:24:22 PM9/25/09
to KML Developer Support - Google Earth Plug-in
Has anyone else noticed that if you try to get the elevation of the
ground at a particular location while in the default starting view, or
even zoomed in somewhere else, the result is something other than the
ground elevation? Or to put it another way, if you want the ground
elevation for a particular location, it has to be in view. This is
easy to accomodate, but I don't recall seeing this requirement in the
documentation.

fraser (Earth API Guru)

unread,
Sep 26, 2009, 7:43:01 PM9/26/09
to KML Developer Support - Google Earth Plug-in
Hi Doug,

Unless the altitude data for the location has been loaded the return
value is 0.
See: http://code.google.com/apis/earth/documentation/reference/interface_g_e_globe.html#fbe6373e3416ee958ba2171016473731

F.

DougH

unread,
Sep 26, 2009, 11:33:44 PM9/26/09
to KML Developer Support - Google Earth Plug-in
Thanks for responding Fraser...

I wasn't getting zero, but rather numbers in the six thousands, which
is probably the average elevation for the thousand or so square mile
area which contained the point I was querying. If you roll the mouse
around when the whole globe is in view, you can see these kinds of
average elevations. There's really no reason to have elevation data
loaded for the entire planet at all times, but you'd think if you made
a query for a specific point, the necessary data could be loaded, and
an accurate result returned.

I wouldn't call this a bug, but either the documentation should
indicate that the accuracy of getGroundAltitude() is related to the
view, or additional data beyond what is required for the current view
should be loaded before generating a result.

The workaround is to zoom in on the point, then make the query, which
in my case added ten thousand feet to the result.

Doug

DougH

unread,
Sep 29, 2009, 10:15:41 PM9/29/09
to KML Developer Support - Google Earth Plug-in
I queried the elevations of the points on linestring, from the
starting globe view, from 5000 feet above the first point, and from
1000 feet above the first point, and graphed the results. I never got
any zeros, but the graphs bore no resemblance to each other
whatsoever. While the accuracy of the results improved by zooming in,
they still deteriorated along the linestring as the queries got
farther along the ground from the first point.

An example of this can be seen by creating a line a couple of miles
long, from low terrain to high terrain, with points every hundred
feet. Zoom in to 1000 feet above the first point, and query the
elevations of all the points in the linestring. At first the
elevations will be very accurate, but they will deteriorate towards
the end of the linestring, with values approaching the average for the
area. Depending upon how the elevation of the first point compares to
the average for the area, a graph that should show a steady accent,
might instead show a steady descent to an elevation thousands of feet
below the actual elevation.

So, the workaround is a little more complicated than I thought,
requiring that the view be respositioned along the linestring, before
each elevation query.

Nymor

unread,
Sep 30, 2009, 5:00:09 PM9/30/09
to KML Developer Support - Google Earth Plug-in
> So, the workaround is a little more complicated than I thought,
> requiring that the view be respositioned along the linestring, before
> each elevation query.

Hi,

Don't know if you've already written something to do this but if not
this might help a bit.

I had a similar requirement - getting GE ground altitudes for points
along a linestring/path so a hacked the following together to give me
that. You're welcome to copy it and adapt where needed.
http://www.thekmz.co.uk/GEPlugin/wip/test/PathElevation/Path_Elevation.htm

(It's based on the Driving Simulator and uses 2 main files -
path_walker.js & path_walker_index.js as well as Roman's
kmldomwalk.js, geplugin-helpers.js and math3d.js)

The utility loads a KML file (there's a variable for that in the main
page) and then, using kmldomwalk, looks for a placemark called "Path"
and loads the coords into an array. Then, on clicking start, it moves
along the path and records the ground altitudes as it goes. (When
finished it pops up an alert that shows the distance covered - that's
just a double check for me that the path is roughly the length I
expect it to be).

Because I need this data in an offline db (the same one that produces
the path.kml) there is a button below the GE window, Show Array Data,
that output to the screen so I can copy it (shift-ctrl-end, the ctrl-
c) and save it in a csv file for import. The data shown is the coord
index (from 1), Lat, Long and Ground Altitude.

As I say don't know if it helps but it works for me so thought I'd
post it anyway just in case.

Regards
Nymor

DougH

unread,
Sep 30, 2009, 8:24:24 PM9/30/09
to KML Developer Support - Google Earth Plug-in
Nymor -

I actually haven't gotten around to writing something to move along
the path, so what you provided will help a lot. I guess I should
submit a feature request or bug report, so others don't have to either
go through the same discovery process we did, or accept all elevation
data as accurate, when it may not be.

Doug
Reply all
Reply to author
Forward
0 new messages