Two Milk, No Sugar

That’s how I take my coffee 🙂 You may have heard of Tim Hortons — a mecca for coffee shops in Canada. Many of us are lost without it during our morning commute. Even though they are seemingly everywhere, there are times when you just can’t find one.

A friend of mine pointed me to a forum working on collecting locations of all Tim Hortons locations in Canada and the US. Wouldn’t it be great to upload these to a GPS which supports GPX format? Or to visualize in Google Earth, for example?

This is easily done using open source geospatial tools. OGR supports the reading and writing of a number of formats, including GPX, KML, GeoJSON, Shapefile, and so on. Here’s how:

  • Download
  • Save as CSV (there is a CSV online, but the XLS has more detailed description of each location)
  • Use OGR’s Virtual Datasource support to read the CSV. Here’s the OVF definition:
<OGRVRTLayer name="th">
<SrcDataSource relativeToVRT="1">./th.csv</SrcDataSource>
<GeometryField encoding="PointFromColumns" x="Longitude" y="Latitude"/>

Transform to your heart’s content:

$ ogr2ogr -f KML ./th.kml ./th.ovf

$ ogr2ogr -dsco “GPX_USE_EXTENSIONS=YES” -f GPX ./th.gpx ./th.ovf

I’ve bundled up a zipfile of various formats for use as an example — have fun!

5 Comments so far »

  1. Using OGR to Visualize Data said,

    Wrote on December 28, 2007 @ 14:03:19

    WordPress 2.3.1

    […] said Tom Kralidis has a great example of using OGR to convert a Microsoft Excel file to KML. GDAL/OGR is integral to so many GIS applications (even […]

    Posted from United States United States
    WordPress 2.3.1
  2. TANTO » Blog Archive » Da excel a gpx e kml: ogr2ogr said,

    Wrote on December 28, 2007 @ 18:12:22

    WordPress 2.3.1

    […] in esso contenute. Oggi lo farò ancora una volta, fortemente ispirato da un piacevolissimo post di Tom […]

    Posted from Italy Italy
    WordPress 2.3.1
  3. fendy said,

    Wrote on March 4, 2008 @ 22:40:53

    Internet Explorer 7.0 Windows XP

    can mapserver & chameleon access google earth KML(read & write) ?? if so, can you give some sample script.

    pleace help me…

    Posted from Indonesia Indonesia
    Internet Explorer 7.0 Windows XP
  4. tomkralidis said,

    Wrote on March 5, 2008 @ 12:09:30

    Mozilla Firefox Windows XP

    MapServer doesn’t have any native KML support. But you could script a process to fetch a KML document and convert with ogr2ogr to something MapServer can render.

    Posted from Canada Canada
    Mozilla Firefox Windows XP
  5. tomkralidis said,

    Wrote on December 8, 2008 @ 07:46:11

    Mozilla Firefox 3.0.4 Windows XP

    Update (08 December 2008): check out for information on KML integration in MapServer.

    Posted from Canada Canada
    Mozilla Firefox 3.0.4 Windows XP

Comment RSS · TrackBack URI

Leave a Comment

Name: (Required)

E-mail: (Required)



Modified: 28 December 2007 08:50:24 EST