Moving from Map My Run to Strava ################################ :title: Moving from Map My Run to Strava :date: 2014-10-11 :category: Software :tags: programming, python, blogging :slug: moving-from-mapmyrun-to-strava :author: Chris Ramsay :status: published :language: en :show_source: True .. contents:: Moving from Map My Run to Strava -------------------------------- .. PELICAN_BEGIN_SUMMARY I have been running a little while now and am always in the habit of taking my phone with me to get some monitoring in on my progress with the aid of GPS and so on. I have been using a really nice app called `mapmyrun`_. It has given me months of good service and what with the moderate amount of running I have done, I have committed a fair few hours worth of data online. Meanwhile I have decided that it would be great to get out running with a group of people rather than on my own all the time, so I have joined up with a very friendly local `running group in Caistor, Lincolnshire`_. Quite a number of them use a different app called `Strava`_, and I thought that I would give it a go based on some positive recommendations from members of the group. You might wonder what this article is doing in the `software section`_ of this site... well, read on. .. PELICAN_END_SUMMARY The Problem ----------- All the fun started when I decided to investigate how to export my running data from *mapmyrun* into a format I could potentially import to another site, such as *Strava*. Simple, I thought, just go to each workout [#]_ in turn and export the session as a `GPX file`_. To clarify, the GPX file standard is intended to be a commonly understood way of sharing GPS data between software applications in XML format. Without getting too technical, GPX files are capable of describing two types of track point sets, where a track point set is a collection of one or more latitude and longitude coordinates: - A route is a set of track points purely describing a route from start point to end point. - A track is a set of track points describing a route that has been travelled, complete with time and date at each point. So, after some investigation I discovered that mapmyrun does allow GPX file export, but only of route data, not track data. One might say that this left me slightly perplexed and not a little disappointed. I did a little research and found Mike Palumbo's `MapMyRide GPX Converter`_; now I wanted something similar but for their running site. It was time to roll up my sleeves hack some quick and dirty code. The Gory Details ---------------- If you are interested in using the code I have put together then it is `available here from my GitHub account`_. It is very rough and ready, but should run out of the box, providing you have the pre-requisites sorted, i.e. Linux box etcetera. Here follows a brief description of what the code does: - Makes a cURL request to the mapmyrun server - specifically the end point that serves background data for the maps rendered on the workout page. - Loads the data recovered from the request above and creates a JSON object. - Creates a datetime object from the start time contained in the data. - Creates a XML GPX skeleton to which the processed data will be added. - For each item in the data series the time and date is calculated and appended to the GPX skeleton, along with lat, lon and altitude data. - When the series has been fully processed the completely formed XML document is dumped into a GPX file locally on the file system. Drawbacks and Improvements -------------------------- Each workout needs to be publically accessible in order for the script to be able to access the data; there is no form of authentication. Actually, the mapmyrun site does have an API which supports OAuth and it may an interesting future exercise to have another attempt at getting GPX data out with it. Running the code is a pretty basic affair also: editing the script before every run is far from ideal. The script would be much improved by being able to accept command line instruction instead. In Conclusion ------------- It is fairly likely that I will stick with using Strava, for several reasons: in my testing so far it seems like a more robust app and in general a little easier to use. Strava does seem to use a little less battery than mapmyrun and in addition the interaction with the GPS on my Android phone is much improved. Also, as previously mentioned, quite a few folks from the running club are already using Strava and therefore there is a wealth of comparison data, routes, personal bests and so on. At some point I shall get round to improving the code; it is there mostly for my benefit, however I am leaving it as an open source project for others to use, abuse or possibly even improve. Good luck, and free your data. .. footnotes .. [#] Workouts are what the mapmyrun site calls individual training sessions. .. links .. _`mapmyrun`: http://www.mapmyrun.com/ .. _`running group in Caistor, Lincolnshire`: http://www.caistorrunningclub.com/ .. _`software section`: {category}software .. _`Strava`: http://www.strava.com/ .. _`GPX file`: http://en.wikipedia.org/wiki/GPS_Exchange_Format .. _`MapMyRide GPX Converter`: http://www.mikepalumbo.com/MMRConverter/ .. _`available here from my GitHub account`: https://github.com/chrisramsay/mapmyrun2gpx