If you know Madison, you know it is a great place to bicycle. This was fortunate for me as a very convincing person suggested I ride in RAW this past summer. To train for this 175-mile ride across the state, I rode around Madison. A lot. And, I used Strava to track my routes. So, now, I have quite a bit of information about where I’ve been cycling.
If you are a Strava premium member, they will make a map of the places you have ridden. I am not, but I am pretty good at parsing code together to do my bidding in R. Thanks in large part to Visual Cinnamon for posting code on visualizing running paths (http://www.visualcinnamon.com/2014/03/running-paths-in-amsterdam-step-2.html), I was able to make my own map of biking routes in Madison. The steps I used are below:
Step 1. Get your GPX files from Strava.
There’s a great article in Strava about how to export your data here. In short, you request your data from your profile and Strava will send you an email with a link to download all of the files (one file per route).
Step 2. Import the GPX files to R.
Importing spatial data into R can be tricky and, like Visual Cinnamon, I could not just use readGPX() to import my Strava GPX files. But, the code modification was minimal. Here is customization that ended up working to read in the Strava GPX files:
Step 3. Make a data frame with route index, latitude, and longitude.
Now that R has read the GPX files, you need to compile these files into a data frame with the spatial information. See http://www.visualcinnamon.com/2014/03/running-paths-in-amsterdam-step-2.html for the code.
Step 4. Plot!
There are many geographical mapping options in R, but I tend to use ggmap (created by David Kahle, https://github.com/dkahle/ggmap ). Here’s the final result:
(An aside: If you are actually training for RAW, don’t just ride around Madison. Get thee out to the Driftless. You will thank yourself when you’re leaving Dubuque on ride day).
And here is the complete code: