Visualization of a Bike Route

by Gong Liu October 15, 2009 05:44

[Just realize that you need Google Earth 5.x to play the video at the end of the article] 

Introduction 

I have a few favorite bike routes that I use for my weekend biking exercise. Depending on my mood and physical conditions, sometimes I choose a route with a strenuous climb followed by a thrilling 40-50 mph downhill. Sometimes I like to have a long, easy cruise along the beaches enjoying the sunshine and sea breeze. Well, other times I want to get a bit more technical about my bike routes than just the readings from my unsophisticated bike computer. Where exactly is the route located? Where is the hardest part of the route? How long and how steep is that slope? So I have assembled a couple of tools to help me to visualize my bike routes in Google Earth. Here is an example:

This visualization presentation has these main characteristics:

  • The route is highlighted (in red) on the map, showing the starting and ending points, as well as mile markers.
  • An elevation profile of the route is overlayed on top of the map.
  • The mile markers help to correlate between the profile and the route on the map, so I can easily find out the elevation and slope of any point on the mapped route.

How to do it? 

Here are the steps involved.  

First, get the route in KML format. There are two ways, manually or with the help of a GPS logger. If the route is short, you can trace it manually with Google Earth. Just click the Add Path button from the toolbar and start tracing, as shown below.

 

You want to trace your route at fairly evenly interval and with enough details. Once you are done with the tracing, the path will be added to the Places pane. Right click the path and select Save Place As from the context menu. Make sure you specify the KML format before hitting the Save button.

If your route is long, you may want to use a GPS logger to record the route and thus save your time doing the tracing manually. I use Pharos GPS Logger, as shown below. The software that comes with the logger allows me to save the recorded route in a KML file. 

Second, once you get your route in a KML file, use the profile tool from GPS Visualizer to generate the elevation profile for the route. The following screenshot shows the web interface of the tool.

 

The interface looks pretty complex, but the key things you need to do include:

  1. Specify the digital elevation model (DEM) you want to use. Note your GPS logger may record elevation data, but it is not accurate enough for our purpose. Also, if your route is outside USA, you have to choose the less accurate data source - NASA SRTM3.
  2. Specify the route KML file on your computer.
  3. Press the Draw the profile button and your profile will be generated as an image (.png). 
  4. Right click the image and save it to your computer.

Third, you need to add your elevation profile to your route KML so that when the KML is displayed in Google Earth the profile is overlayed at the top-left corner of the map. This is accomplished by using the <ScreenOverlay> emelent, something like:

    <ScreenOverlay>
      <name>Profile Overlay</name>
      <visibility>1</visibility>
      <color>c8ffffff</color>
      <Icon>
        <href>url_of_your_elevation_profile_image</href>
      </Icon>
      <overlayXY x="0" y="1" xunits="fraction" yunits="fraction" />
      <screenXY x="0" y="1" xunits="fraction" yunits="fraction" />
      <rotationXY x="0" y="0" xunits="fraction" yunits="fraction" />
      <size x="0.9" y="0" xunits="fraction" yunits="fraction" />
    </ScreenOverlay>

It is assumed that you have uploaded the profile image to your website and know its URL. Note that the color of the overlay is set semi-transparent so that the map underneath can show through partially. Also, the overlay width is set 90% of the map width, leaving enough room to the right for the Google Earth navigation controls.

Fourth, now you can display the route and the profile in Google Earth. So far so good. But without mile markers on the route, you can't really cross reference the two. Of course, you can use Google Earth Ruler tool to measure the distance along the route and then use Add Placemark tool to add mile markers manually. That sounds tedious though. So I wrote this little program called MileMarker in C#. It reads a KML file (containing a <LineString> element) and adds mile markers as placemarks to it. The following screenshot shows the interface of the MileMarker tool:

 

You can download the MileMarker tool executable from the following link:

MileMarker.zip (6.62 kb)

My favorite bike routes

Here is a list of my favorite bike routes. You can download the KMLs that have been enhanced with the above visualization process.

Route Level Length Comments Download
Hawthorne Hard 15.0 mi A series of light climbs and a long steep climb followed by a steep downhill.
Crenshaw Hard 9.8 mi Features a 5-mile continuous steep climb followed by a steep downhill. Narrow shared lane for the first 3 miles.
Lighthouse Intermeditate 16.1 mi Rolling hills. Exclusive bike lane for most parts.
Marina del Rey Easy 28.6 mi Along the beaches, exclusive bike lane.

Note: you need to have Google Earth on your computer in order to view a KML/KMZ file. You can download a free version of Google Earth here. In my opinion, Google Earth is one of the best free mapping programs. It's worth your effort to download and install it.

Touring a bike route and adding background music

Once you have loaded your route KML file into Google Earth, you can tour the route using Google Earth's touring feature. You just highlight the route path and hit the Play Tour button, as shown below (left). The tour player will show up at bottom-left corner of the map screen, as shown below (right). 

  

As you are playing a tour, you can also record it with the tour recorder, as shown above (right). You display the tour recorder by pressing  button in the Google Earth toolbar. When you finish/stop recording a tour, you can save it using the Save button on the tour player. The saved tour will show up in the Places pane. As everything in the Places pane, a tour is also in KML format but with elements in the Google Extension Namespace. The tour recorder also allows you to add sound cue, such as narrative or background music, to your tour from a microphone connected to your computer. Of course, if you have a prerecorded sound cue, you can insert it into your tour by editing the tour KML directly. Here I'll show you how to package your route KML, its recorded tour and a piece of prerecorded background music into one KMZ file so you can publish it on the web and share it with other people.

  • Prepare your route KML, elevation profile and everything as described previously. Let's name this file as doc.kml.
  • Tour the route and record the tour. You can adjust touring options at Tools -> Options -> Touring. Save the tour as tour.kml.
  • Raid your music collection and find a piece you like or record your own. You may need to edit it with a sound editor to match the tour length. Let's name it backmusic.mp3.
  • Create the following folder structure: 

    

  • Put doc.kml in BikeRoute folder, tour.kml in tour folder and backmusic.mp3 in sound folder.
  • Open tour.kml in a text editor and insert the background music as <gx:SoundCue> like so: 
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
<gx:Tour>
   <name>Howthorne Route Tour</name>
   <description>Howthorne Route Tour with background music</description>
   <gx:Playlist>
      <gx:SoundCue>
         <href>sound/backmusic.mp3</href>
      </gx:SoundCue>
      <gx:FlyTo>
         ...
      </gx:FlyTo>
      ...
   </gx:Playlist>
</gx:Tour>
</kml>
  • Open doc.kml in a text editor and include the tour like so:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:kml="http://www.opengis.net/kml/2.2" xmlns:atom="http://www.w3.org/2005/Atom">
  <Document>
    <name>Hawthorne Route</name>
    <NetworkLink>
       <name>Tour</name>
       <refreshVisibility>1</refreshVisibility>
       <flyToView>1</flyToView>
       <Link><href>tour/tour.kml</href></Link>
    </NetworkLink>
    ...
  </Document>
</kml>
  • Select everything inside the BikeRoute folder, right click, and select Send To -> Compressed (zipped) Folder. This will generate a doc.zip file.
  • Rename doc.zip to whatever name you like and change its extension to kmz. Now you can upload the KMZ file to your website and share it. 

Note:

  • You can also package the elevation profile image (.png) inside the KMZ file. In this case, you need to change the URL inside the <ScreenOverlay> tag of the doc.kml file to reference a local file.
  • You can reference a remote mp3 file as your background music in the tour.kml file, and thus reduce the KMZ file size significantly. However if you are experiencing choppy sound during playback of the KMZ file, your best bet is to package the mp3 file inside the KMZ.
  • If you host your KML/KMZ files in a web hosting environment, make sure you talk to the hosting company and let them enable the KML/KMZ MIME types on their web servers, because by default they are blocked. 

When someone downloads your bike tour KMZ file, he can play it in Google Earth by expanding the package, selecting the tour (the item with a camera icon), and pressing the Play Tour button, as shown below.

 

You can try out one of my bike tours here . Just sit tight, crank up your speakers and enjoy the ride!

About

A seasoned computer professional. A tofu culture evangelist...
more >>

Tag Cloud

Calendar

<<  April 2017  >>
MoTuWeThFrSaSu
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567

View posts in large calendar
Copyright © 2008-2011 Gong Liu. All rights reserved. | credits | contact me
The content on this site represents my own personal opinions, and does not reflect those of my employer in any way.