Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
up vote 0 down vote accepted

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

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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