Adding the geographical peaks to Google Earth

My current version of Google earth doesn’t show any peak. I describe below how I imported them from OpenStreetMap. Here is the end result:

google-earth-osm-peaks

google-earth-osm-peaks-2

  • Download an OSM file for the region you are interested in, for instance from geofabrik. I will use “provence-alpes-cote-d-azur.osm.bz2” here
  • Decompress it:
    bzip2 -d provence-alpes-cote-d-azur.osm.bz2
  • Extract the peaks with Osmosis:
    osmosis -q --rx provence-alpes-cote-d-azur.osm --tf accept-nodes natural=peak --tf reject-ways --tf reject-relations --wx provence-alpes-cote-d-azur-peaks.osm
  • Convert it to KML, removing the timestamps:
    gpsbabel -i osm -f provence-alpes-cote-d-azur-peaks.osm  -x transform,wpt=trk -o kml -F - | grep -vi 'timestamp.*when' > provence-alpes-cote-d-azur-peaks.kml

Finally, open the KML file in Google Earth.

Update 2012-12-04 : you can also modify the OSM file to include the elevation in the names, for a better overview in Google Earth. For that, you will need an XML processor. I use xsltproc here, from libxslt.

<?xml version="1.0"?>

<xsl:stylesheet  xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">       
  <xsl:output indent="yes" method="xml"/>
  
  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>
 
  <xsl:template match="@*|*|processing-instruction()|comment()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match="tag[@k='name']">
    <xsl:element name="tag">
      <xsl:attribute name="k">name</xsl:attribute>
      <xsl:attribute name="v">
        <xsl:value-of select="@v"/>
        <xsl:text> (</xsl:text>
        <xsl:value-of select="../tag[@k='ele']/@v"/>
        <xsl:text>)</xsl:text>
      </xsl:attribute>
    </xsl:element>
  </xsl:template>
</xsl:stylesheet>

Before you call gpsbabel, use this XSLT sheet to process the OSM file:

xsltproc peaks.xslt provence-alpes-cote-d-azur-peaks.osm   > provence-alpes-cote-d-azur-peaks-processed.osm

It’s of course possible to optimize this process. If you do, it would be nice to post your improvements here.

Advertisements
This entry was posted in GPS. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s