Altitudes and polygons in Google Earth

When creating the Santa Tracker we made use of some code we had previously written for creating arcs in Google Earth. As we noted in that post, however, the arcs use relative altitudes, but for smaller arcs there can be noticeable dips and bumps in line with the underlying terrain. The other alternative is to use absolute altitudes but this results in arcs that end at a fixed altitude either underground or up in the sky, depending on the altitude one sets and the altitude of the ground at the ends of each arc. Neither of these possibilities was satisfactory for the Santa Tracker as it often shows the arcs up close and Santa himself is shown following the arc and would bounce around alarmingly as he flies over mountains and rivers below.

The cause of the problem is simple. KML paths and polygons that are drawn in KML do not have any altitudes associated with each point. It is possible to set the whole path or polygon to either follow the terrain or be at a specific altitude, but you cannot adjust the altitude of individual points. KML does, however, support altitudes and KMLs derived from other sources, such as GPS’s, which include altitude, do correctly display the altitudes in Google Earth, and we actually used this feature when creating the arcs mentioned above.

To draw nice smooth arcs that end at ground level at each end we need to know what the absolute altitude of ground level is for each end of the arc – but this is not available in the KML file. So we did some investigation and discovered that Google provides an elevation API as part of the Google Maps API. So, to create our arcs we first obtain the altitudes of all the points along the path or polygon and then we can draw nice looking arcs and give Santa a smooth ride.

We also thought that maybe other people might find a use for code that takes a KML of a path or polygon and adds in the altitude data from the Google Maps Elevation API. So, here it is:

Simply select a KML containing paths or polygons and the script will add altitude data from the Google Maps Elevation Service. You probably won’t see any difference in the resulting KML file when loaded in Google Earth, as the paths or polygons will still be at ground level. However, if you check the properties of a path or polygon you will see that it now shows various altitudes instead of an altitude of zero. Its real use is in cases where you want to do further processing, as we did for creating arcs. If anyone finds this useful do let us know in the comments what application you found it useful for.

Note that the Elevation Service is not intended to be used to extract large quantities of elevation data, so don’t expect to be able to use it to copy whole areas of elevation information into other applications.

About Timothy Whitehead

Timothy has been using Google Earth since 2004 when it was still called Keyhole before it was renamed Google Earth in 2005 and has been a huge fan ever since. He is a programmer working for Red Wing Aerobatx and lives in Cape Town, South Africa.






PLEASE NOTE: Google Earth Blog is no longer writing regular posts. As a result, we are not accepting new comments or questions about Google Earth. If you have a question, use the official Google Earth and Maps Forums or the Google Earth Community Forums.

Comments

  1. I made lots of marathon animation, I show the profile image of marathon path on screen, then a yellow point jump on the profile follow the moving position synchronously. This profile picture is captured from Google Earth elevation profile and then edited by PS.
    If I do not get GPS altitudes that provided by others, then I usually get the altitudes by ridewithgps. Because the different sources, so the yellow points are a little bit inconsistent with the profile.
    This time I try your tool, because the points of the path is more than 1100, so I have to divide to 4 pieces to carry out, and finally connect to a path.
    The final results is here, looks improved some. Many thanks for your tool, I will continue to use it later.

  2. http://Todd says

    Hi Timothy,

    I don’t think the code is working, or I may be doing something wrong. When I receive the file the lines are still flat to the ground–Even after I modify the elevation in properties. Any Suggestions?

    Thanks,

    Todd

  3. http://Jainesh says

    Hi Tim,

    The tool works great. I wanted to find the average elevation within the polygon in addition to the min and max elevation. Any suggestions

    Thanks
    Jainesh



PLEASE NOTE: Google Earth Blog is no longer writing regular posts. As a result, we are not accepting new comments or questions about Google Earth. If you have a question, use the official Google Earth and Maps Forums or the Google Earth Community Forums.