<p><div><div><div><div data-show-faces="false" data-height="21" data-width="100" data-layout="button_count" data-send="true" data-href="https://www.r-bloggers.com/where-do-you-run-to-map-your-strava-activities-on-static-and-leaflet-maps/"></div></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://rcrastinate.blogspot.com/2018/01/where-do-you-run-to-map-your-strava.html"> Rcrastinate</a></strong>, and kindly contributed to <a rel="nofollow" href="https://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>So, <a rel="nofollow" href="https://labs.strava.com/heatmap/#7.00/-120.90000/38.36000/hot/all" target="_blank">Strava’s heatmap</a> made <a rel="nofollow" href="http://www.wired.co.uk/article/strava-military-bases-area-51-map-afghanistan-gchq-military" target="_blank">quite a stir</a> the last few weeks. I decided to give it a try myself. I wanted to create some kind of “personal heatmap” of my runs, using <a rel="nofollow" href="https://strava.github.io/api/" target="_blank">Strava’s API</a>. Also, combining the data with <a rel="nofollow" href="http://leafletjs.com/" target="_blank">Leaflet</a> maps allows us to make use of the beautiful map tiles supported by Leaflet and to zoom and move the maps around – with the runs on it, of course.</p>
<p>So, let’s get started. First, you will need an access token for Strava’s API. I found all the necessary information for this in <a rel="nofollow" href="https://medium.com/@annthurium/getting-started-with-the-strava-api-a-tutorial-f3909496cd2d" target="_blank">this helpful “Getting started” post</a>. As soon as you have the token, you have access to your own data.</p>
<p>Now, let’s load some packages and define functions for getting and handling the data. For the get.activities() function, I adapted <a rel="nofollow" href="https://gist.github.com/nicokosi/241331f67692945ddca4e4ea2cc0597d" target="_blank">code from here</a>.</p>
<p><span>library(httr)</span><br><span>library(rjson)</span><br><span>library(OpenStreetMap)</span><br><span>library(leaflet)</span><br><span>library(scales)</span><br><span>library(dplyr)</span><br><span><br></span><span>token &lt;-“</span>