I am looking to create my own 'heatmap' of all the bike rides I have recorded using the app Strava in QGIS.

I have over 450 individual gpx files and would like to merge the track points layers into one single shapefile so I can join them to a polygon layer and symbolise by join_count as seen in this example:

enter image description here

Some of my gpx files contain 'ride' in the file name and others 'run', I'd like to filter the files leaving only those with 'ride'.

How can I achieve this efficiently using QGIS?

3 Answers 3


Use the ogr2ogr command line tool, that is distributed with QGIS. In Windows, open the OSGeo4W Shell from the QGIS program group and enter

for %p in (path_to_gpx_files\*ride*.gpx) do ogr2ogr path_for_output\gpx.shp -append %p track_points -fieldTypeToString DateTime

The equivalent command in a Unix bash shell would be

for file in path_to_gpx_files/*ride*.gpx; do ogr2ogr path_for_output/gpx.shp -append "${file}" track_points -fieldTypeToString DateTime; done

Make sure the output file (gpx.shp) doesn't exist before, then ogr2ogr will produce one single shapefile from all gpx files with "ride" in it. There are some notes about the ogr gpx driver at http://www.gdal.org/drv_gpx.html .


I know this is late but it might help others one day. There is a QGIS plugin called Batch GPS Importer which I explained more in this answer.

The latest version can filter out files using prefix and suffix text. Batch GPS Importer

I hope it helps.


You can import multiple GPX files at a time, although you will be prompted each and every file for the data layer you want. With over 400 traces that's not going to be fun.

You might want to look at ogr2ogr. This is the Swiss-Army-Knife of geo file conversions, it will convert almost any geoformat into any other compatible (vector/raster) geoformat.

an ogr2ogr call looks something like

ogr2ogr -f "ESRI Shapefile" example.shp example.gpx

You can call it programatically (e.g. from a python script, .bat file or bash script) to iterate over each ride*.gpx and convert it to a shapefile, for example.

Having said that, I couldn't get this to work on a couple of random gpx traces I downloaded from OpenStreetMap (ogrinfo didn't like them either, although QGIS loaded them). But I was able to open GPX files from another source.

Try running

ogrinfo example.gpx tracks

and see if you get any useful output. If you get a list of drivers, it's failed.

Your mileage may vary, it's worth a go.

Note that each shapefile will end up with its own directory, so if you don't want the hassle of writing code, you could try CSV instead.. see this blog post.

To do the merging, you could (using code) copy all the shapefiles into a single directory, then use the Vector > Data Management tools > Merge shapefiles into one

If you're fond of the hexbin style you illustrated, you might like to look at the MMQgis plugin. This allows hexagonal grids to be created, which you can then use to do the 'points in polygon' analysis.

  • 4
    In Windows I opened the OSGeo4W Shell from the QGIS Program Group and tried for %p in (C:\Data\*.gpx) do ogr2ogr gpx.shp -append %p track_points -fieldTypeToString DateTime. gpx.shp must not exist before, then ogr2ogr produces a single shapefile.
    – Redoute
    Commented Aug 23, 2015 at 19:51
  • 1
    You should write this up as an answer @Redoute!
    – Alex Leith
    Commented Aug 23, 2015 at 22:57
  • @Redoute Yes please can you write up as full answer? Thanks
    – MFBawls
    Commented Aug 24, 2015 at 13:55
  • 1
    translation of excellent suggestion by @Redoute for Linux users, it works like a charm... #!/bin/bash for i in $( ls ./*.gpx ); do ogr2ogr gpx.shp -append $i track_points -fieldTypeToString DateTime done
    – Steven Kay
    Commented Aug 24, 2015 at 14:28

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.