bikesI love animating bikesharing systems, but without GPS data it looks like people travel in straight lines, from bike-out to bike-in. So to get a better idea of how cyclists really travel across the city, I wanted to investigate mapping multiple GPS tracks.

The first step is finding data. Strava has a huge repository of bike data, but you can’t access a trips’s GPS data unless you are connected to that person, or if they otherwise grant you access. And even then when you download the GPS data the GPX file doesn’t include timestamps. You can get an idea of the potential of Strava’s data from this “Beautiful Weekend” video made by BikeArlington using VeloViewer.

I decided to try to collect my own GPS data by asking a local monthly bike ride, the DC Bike Party, to record their outing and send me the data. Their April ride attracted 650 riders, but I got only 5 responses, and one of those I had to reject for not having timestamps. But four cyclists is good enough for an experiment to learn more about the process.

The next step was data munging. One participant sent me two separate GPX files, for before and after the break at the bar. It was easy enough to merge them by taking the trkpt tags from one file’s trkseg section and adding them to the other file’s trkseg section. Another participant’s GPX file wasn’t syncing up with the others. To correct it, I just manually edited the timestamps using a global search & replace for the hour field.

To create the animation, I once again used Processing (a compact version of Java). Converting timestamp strings into date values is always tricky. In this case, some of the files had seconds with decimals values, and some without. I used one of Java’s many convoluted conversions methods, first trying SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"), and if that failed, then trying SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'").

One of the hardest parts of the animation is getting the background. To get a map, I use OpenStreetMap, which now has an export function. But it’s still tricky to get an image where the boundaries match up to the range of latitudes and longitudes.

Here’s what the result looks like:

The video reveals other problems. If the route covers too much territory, it’s hard to discern differences between the riders, since the space between them is relatively small compared to the area covered by their routes. So if I were to design a course specifically for creating a GPX animation, I would design a tighter route, perhaps no wider than a mile. But the results do show it is worthwhile to try again with another ride, this time with more than four people!

Animating a Group Bike Ride

Leave a Reply