2014/02/21

Converting kmz to gpx

Recently, I have started to collect data from GPS during bicycle commutes using an Android smartphone. This job is done by MyTracks. I have tried other applications, but this one worked out best.

MyTracks, by default, creates a kmz file, which is a Keyhole Markup Language (kml) file (or various) bundled with other resources into a zip file. It can export to other types, but kmz has some advantages, like photographs embedded on markers.

Loading this file in Google Maps directly from Google Drive was straightforward, but it requires an internet connection. I wanted to view, and maybe edit, the file offline. I have tried loading the kmz file directly on various applications under Linux, but the I have only achieved getting the begin and end points this way.

So, I converted the kmz file to gpx (GPS Exchange Format) using gpsbabel and the track was correctly imported (I am using JOSM - Java OpenStreetMap on the computer).

How to Convert

Given a kmz file, to get a gpx one:

$ unzip -p myfile.kmz doc.kml | gpsbabel -i kml -f - -o gpx -F myfile.gpx

myfile.kmz is the file to be converted. gpsbabel does not convert kmz directly to gpx, so it is necessary to extract the kml file that inside kmz (which is doc.kml in the example). The file is piped to gpsbabel which will save the new gpx file myfile.gpx. If there is more than one kml file, the processes must be repeated for every kml.

  • gpsbabel (accessed 2014-02-20): project website;

  • kml (accessed 2014-02-20): Keyhole Markup Language file type;

  • gpx (accessed 2014-02-20): GPS Exchange Format file type.

Revision History

Post built on: 2014-02-21 00:00:18
Last modified on: 2014-02-21 00:00:13
First published on: 2014-01-21

Revision Date Description
1.00 2014-02-21 Initial Version. Published.