Using Strava Data to Build My Own Custom Heatmap

And I rode… I rode so far a-way-ay-ay…

Eric Bias
6 min readJan 17, 2021

For those of us in NYC who’ve spent the better part of an entire year quarantining ourselves due to the pandemic, it’s often been pretty difficult finding ways to cope with the isolation. For me, while I’m thankfully privileged enough not to have lost a loved one or a job this year, I’ve mostly tried to use this time as much as possible for self-improvement, say, more time exercising, less time in front of the TV with my Switch. I can’t say it’s been as entirely successful as I hoped (I could go on for days about the self-imposed noose of “productivity”), but it’s a welcome start.

Anyway, biking around the city has been a major hobby of mine for 10 years, so what better time to get outdoors beyond the confines of my one-bedroom and explore town and country on two wheels?

So, with a particular focus on exploring places I’ve never ridden to, I did, recording each ride with Strava, a fitness app that captures geolocation and fitness data for runners and cyclists.

Inspired by this homemade heatmap I found on r/NYCbike, I wondered if I could compile something like that for myself that would show everywhere I’ve ridden in the past year, all in one map.

The Brooklyn and Queensboro bridges are my go-tos, apparently.

I knew Strava had the ability to produce something like that, remembering that they briefly made the news back in 2018 when their heatmaps gave away the locations of some sensitive military bases, including Area 51. Unfortunately for me, however, the feature is locked behind their premium tier.

The Reddit map was built using R, but given my R skills are pretty basic, I started to wonder how (if at all) I could collect the data on my rides and display them all at once. In short I ended up downloading each ride one by one, passing them through several file conversions (unnecessarily I later learned), and then stitching them together in QGIS, an open source GIS program.

Was my method more complicated than it needs to be? Yup. Is there a better method? Probably — pay Strava! Don’t be influenced by my cheapness.

But if you do want to create a heatmap from scratch, here’s my not-so-quick-and-very-dirty way.

The Method

Strava includes an option to bulk download all user data, including .gpx files on each activity that QGIS will recognize, but I found that if you do that it doesn’t differentiate between rides and runs — the exported .gpx files are named with apparently random strings of numbers that to tell you nothing about the actual activity. I also record my weekend runs in the app, so that was a problem.

Herbert Von King Park is certainly recommended as a jogging route BTW, given how many times I’ve jogged it.

A little more digging let me know that I can download activity data one by one as a .tcx file by entering the individual activity page and appending “/export_tcx” on the end of each URL, which triggers a download. First hurdle cleared!

I filtered a page in my profile listing all my recorded bike rides for the year, which totaled 27. (Some of these were commutes to work and back, which I chose later in the year not to record.) I then exported each file and tried plugging them into QGIS, only to discover that QGIS doesn’t recognize the format. So the next step was finding how to convert a .tcx into something that I know QGIS can use, like a GeoJSON.

Unbeknownst to me I would have saved this step by just poking around on the page a bit longer:

Note to self: Always click on the three dots!

Anyway, I found a converter program here which converts .tcx files to .kmls. Again, I didn’t know that QGIS could handle .kmls (it can!), so I went in search of another online file converter that could change .kmls to GeoJSONs. Unfortunately both of the converters would only work file by file, so it took quite a while to get everything set. Don’t be me folks, do your research.

With all my files now in the desired format, I set about building my map. I only needed the route data for each activity, so when prompted to choose what vector layers to add with each file I selected only the LineString geometry type. Repeat for each file.

Pleas direct ur eyes away form my bad spelling.

For the path I wanted something that looked similar to Strava’s default heatmap, so I selected a bright orange line with a .75 width and 40% opacity, so multiple lines overlaid on each other would appear brighter than more lightly traveled routes. My basemap was Dark Matter (Retna) with no labels, sourced through the QuickMapServices plugin. (I found the labels added unnecessary clutter to the map.)

Feel free to customize! Access this by right clicking on each feature in the Layers pane and selecting Properties.

Takeaways!

As I said, there are faster, more efficient ways to get this done. I could have downloaded each activity individually as a .gpx from the activity page without having to go through so many tedious conversions. The lazy way is not always the best. But that’s how you learn!

I’m happy with what I could produce though, with my limited knowledge. And one noteworthy advantage of this method is that you can customize the heatmap to your liking, with a unique basemap, route colors, and styles. You can even include multiple styles in one map. For example, I could have plausibly plotted my runs and rides together and colored them differently in one map to chart my entire fitness “journey.”

What have I learned? For one, I really don’t like biking through Queens too much, either due to my inexperience as a Brooklynite, but I think more due to my perception of Queens as too car-centric for my riding comfort. So many highways to cross! I should also make more of an effort to explore Eastern Bronx beyond one trip to the Kensico Dam.

Route 9W on the left, South County Trail in the middle, Bronx County Parkway on the right.

A couple routes were clear favorites of mine, notably the ever-popular Hudson River Greenway, Bedford Avenue to the Belt Parkway path (if you haven’t been to Shirley Chisholm State Park, there are some lovely paved trails on the north side worth exploring), and the South County Trail into Westchester County. The illustration cuts off one ride of note, a particularly grueling trip upstate to Brewster to the end of the North County Trail.

It goes without saying that NYC is a huge city, and clearly there are still a lot of places still left to see. Hopefully, by the time I put together next year’s map, I will have explored some of them with friends instead of solo. And maybe I’ll be able to build it in R next time…

--

--

Eric Bias

Just a standard issue progressive NYC millennial by way of WV. Interests in migration, foreign affairs, social science, & data viz. Have bike, will travel.