I downloaded a KML track from Google Latitude. The service allows to download the tracked route from the user's profile providing a link such as:



I would like to convert the .kml file into a Shapefile. I am running Ubuntu. I am a bit familiar with QGIS and ogr2ogr. Therefore, I tried the following command as usual:

$ ogr2ogr -f "ESRI Shapefile" example.shp example.kml
ERROR 4: No layers in KML file: example.kml.
Unable to open datasource `example.kml' with the following drivers.

Quantum GIS

QGIS states "invalid data source" when I open the .kml file as a vector layer.

Kml2Shp Online

I also tried Kml2Shp Online without success. It is not able to read any information either:

Entities found:
# Points: 0
# Paths: 0
# Inner Polygons: 0
# Outer Polygons: 0

Google Earth / GPSBabel

Furthermore, I found out that Google Earth is not capable of exporting GPX. Google refers to GPSBabel which converts KML to GPX using the following command:

$ gpsbabel -i kml -f ~/Desktop/example.kml -o gpx -F ~/Desktop/example.gpx

However, in my case it outputs a GPX file without location data.

GPS Visualizer

As a first success I found the website GPS Visualizer. Uploading and converting the file their actually produces a valid GPX file.

Still my question remains to be open:
Is there a command line tool that is capable of converting the file? I do not want to upload the tracking data to yet another website for the conversion.

  • You can load the KML into QGIS and save as shapefile natively.
    – Mapperz
    Commented May 22, 2013 at 19:42
  • 1
    @Mapperz Please re-read my question: I already wrote that QGIS does not accept the file.
    – JJD
    Commented May 22, 2013 at 20:13
  • 1
    Are you sure it is a KML file ? size bigger than 0. It could be KMZ file (which qgis didnt support while ago , i think) Commented May 22, 2013 at 20:20
  • @simplexio All I can tell you is that Google Latitudes offers a download link as KML. I updated my question accordingly.
    – JJD
    Commented May 22, 2013 at 20:26
  • And its has size and there is data when you use 'cat file' ? Commented May 22, 2013 at 20:32

5 Answers 5


Working (albeit cumbersome) solution to convert KML-/KMZ-files with <gx:Track>-Extension to gpx/csv/tcx, via Googles MyTracks-App.

I tried to import a .kmz-file to QGIS, containing a GPS-track as <gx:track>-Element. (Track was recorded with MyTracks-App on Android. I only had the .kmz.)

After numerous attempts, using various tools (GPS-Tools-PlugIn, GPSBabel, some online tool, etc.) which never converted the track (i.e. LineString) but only the point features, i remembered that MyTracks offers an import-option as well. So imported the .kmzto MyTracks , exported the track as .gpx and was finally able to import the .gpx to QGIS. Job done.

Here is a brief, illustrated HowTo, just in case someone is interested (sry for german UI):

1.) Copy .kmz to MyTracks/kml on device.

2.) Import all external KML-tracks in MyTracks-App

3.) Select imported track and export to external storage as GPX, CSV or TCX.

4.) Locate exported track in corresponding directory (i.e. MyTracks/gpx, MyTracks/csv or MyTracks/tcx) and copy/move to PC/Mac.

5.) Eat cake!

6.) Proceed with original task. (e.g. import to QGIS)


Not the operating system you want, but BaseCamp by Garmin can read your kml file, and exporting to csv gives a file that can be added with delimited text to QGIS. The data leads to Indonesia.


Unfortunately, KML is not a very strict standard. That means that almost every form of data storage is allowed, as long as it is valid XML. The kml drivers incorporated in OGR, QGIS and others only support the storage format the developer had as example. If you face a huge number of KML files, it might be worth writing a XML parser style sheet that picks the coordinates and outputs them in a simple format like CSV:



I finally found a script which converts KML to GPX. That's good enough. It is written by ONO Hiroki. All credits belong to him. On request he rewrote the script within one day to match the current format of KML files by Google Latitude. I put the old and current version of the script to the following location.

  • 3
    I opened a ticket for supporting the Google Latitude format in the GDAL KML driver: trac.osgeo.org/gdal/ticket/5095
    – AndreJ
    Commented May 27, 2013 at 11:09
  • 1
    ... and already fixed in the latest GDAL libkml driver with r6053. Unfortunately, this driver is not included in the gisinternals Windows builds.
    – AndreJ
    Commented May 28, 2013 at 19:55
  • @AndreJoost That was awesome fast. Thank you for the report!
    – JJD
    Commented May 29, 2013 at 14:27

Hi JJD, If you have QGIS Installed on Ubuntu, you can convert KML to SHP by following these step:(In QGIS GUI, not command mode)

  1. Add your .KML file by add vector layer button
  2. Selecting file type Keyhole Markup Language
  3. Adding your file and right-click on layer name and choose Save As
  4. Save it as a new file and select Esri shape as a file type
  5. Now you have a SHP on your hard disk

Hope this will help you.

  • 2
    Please re-read my question: I already wrote that QGIS does not accept the file. You can try it with the file yourself.
    – JJD
    Commented May 22, 2013 at 20:13
  • check your kml is vaild first & test a different file.
    – Mapperz
    Commented May 22, 2013 at 20:35
  • 1
    If having a line from that track is enough its a solution (I think cause its a KML track QGIS couldn't open it as regular KML) Commented May 22, 2013 at 20:53
  • 1
    Go to gpsies.com/convert.do and upload your data and convert it to GeoJSON track (in convert to track menu) and then add it to qgis as a vector layer and save it as shp. Hope that works fine. Commented May 22, 2013 at 20:55

QGIS on Ubuntu

Vector (select directory) browse for kml file (drop down list) then add

Then select the features (point, lines, polygons etc) select all or individually

enter image description here

enter image description here

enter image description here

Source KML tested https://developers.google.com/kml/documentation/KML_Samples.kml

  • 2
    Well, as the user said, it's not working. Just check the kml he links :/
    – RobinC
    Commented May 22, 2013 at 20:35
  • they are blocked - KML can only be simple lines and polygons.
    – Mapperz
    Commented May 22, 2013 at 20:37
  • 1
    No, this kml is a GPS track, with coordinates like this : <gx:Track> <altitudeMode>clampToGround</altitudeMode> <when>2012-02-27T08:44:37.614-08:00</when> <gx:coord>95.425701 5.4245077 312</gx:coord> <when>2012-02-27T08:45:16.653-08:00</when> <gx:coord>95.4175155 5.4290813 125</gx:coord> <when>2012-02-27T08:45:44.686-08:00</when> <gx:coord>95.4120326 5.4325564 103</gx:coord> <when>2012-02-27T08:46:45.641-08:00</when> etc.
    – RobinC
    Commented May 22, 2013 at 20:38
  • 1
    I tried to open it in Google Earth, and save it to kml/kmz from there (sometimes works as KML can contains links instead of coordinates), but this strange format remains the same.
    – RobinC
    Commented May 22, 2013 at 20:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.