I want to show a number of GPX files in a TileMill map. Here's the process that I thought would work:

  1. gpsbabel -i gpx -f "$myfile" -o kml,lines=1 -F "$myfile.kml"
  2. Add as layer in Tilemill, style with line-width: 2; and voila.

But no. Only points are being rendered, not the lines between them.

The generated .kml files contain <linestring> elements, which I would have thought is the key:


Is the problem a shortcoming at the TileMill end, or something in how I'm converting the files? Unfortunately none of the other formats supported by TileMill (GeoJSON, Shapefiles...) are supported by GPSBabel.

Other options? I'm using PostGIS, so a way to load them straight into the database would also be fine.

1 Answer 1


In the end using GDAL's ogr2ogr worked:

for f in *.gpx
  echo $f
  ogr2ogr -f GeoJSON "$f.json" "$f" routes

Then, either load the GeoJSON files directly into TileMill, or load them into PostGIS first:

psql -d gis -c "drop table ogrgeojson;"
# Annoyingly we need to specify these properties the first time we import, then use -append afterwards.
extraargs="-nlt MULTILINESTRING -lco DIM=2"
for f in /usr/share/mapbox/project/myproject/*.json
  echo $f
  ogr2ogr -f "PostgreSQL" $extraargs  -a_srs "EPSG:900913" PG:"host=localhost user=ubuntu dbname=gis password=..." "$f"
  extraargs="-append -nlt MULTILINESTRING"

End result:

Cycle tours around Victoria

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.