Tracking my movements on the football pitch with Fitbit

Pierre Delarroqua
Laces Out
Published in
5 min readJan 30, 2017

I recently celebrated my birthday, and my wonderful girlfriend offered me a smartwatch in order to track my fitness activity. I mostly run and play football, and when it comes to track your movements while jogging, my brand new Fitbit Surge does the job almost perfectly.

The Fitbit Surge in red

I decided to test its effectiveness on the football field, so I wore it during a game in Paris. Fitbit allows you to export your data in a .TCX format. I did it, and then imported it in Google Earth to check whether the GPS was accurate or not.

You can see the result on the screenshot below. I think this is pretty neat, and reflects pretty much my style. I play defending midfielder, and you can see I try to cover as much area as possible !

My GPS tracking data in Google Earth

I then used the python package lxml to parse these data in a friendlier format. I extracted my positions in latitude and longitude every second, as well as my heart rate, which I will use later on. You can see the first 5 rows of the new dataframe.

Extract of the data I used

Afterward, I used Folium, which helps you visualize your python data on a Leaflet map. I was able to create quickly a Heat Map of my different positions.

Heat Map with Folium

As you can see, it is build over OpenStreetMap, but I thought Google Map would do a better job to display a satellite version of the field.

I built a small python app with Flask in order to pass the data from python to javascript. The code is available here, along with other analyses and data of this post.

You can see the final result below — it looks like the Eiffel Tower !

Heatmap Layer of Google Maps API

Note that I am lazy, and I didn’t invert the lat-long coordinates for the second half of the game, in order to represent my real average position of the field. I may do that later.

To give you another example, you can see below two heat maps of another game where I played left center-back, one for each half. As you can see, I didn’t leave much my initial position in the first half and played pretty low, while I was much higher on the field for the second half and more spread.

Same player, two different halves

Anyway, I wanted to do something else with those data, so I didn’t stopped here. Indeed, I wanted to learn D3.js for several months, and it was the perfect opportunity to do just that !

I thought that it wouldn’t take long, but as I was pretty new to javascript, it took me waaayyy more time than I expected. The language is really different from Python or R, and I spent several hours making those transitions work.

Basically, I wanted to represent my movements on the pitch every second, to see myself moving dynamically, and being able to press play and pause. Also, I wanted to change the color of the circle (representing my position every second) with the value of my heart rate. It starts as light green, and becomes really red after a sprint or a long period running. You can check the clock of the game at the top right of the field.

Click on the picture to play a little, or on this link !

My first D3.js project

You can follow my movements during the second half of the game than I mentioned previously, as well as my heart rate. Have fun !

While Fitbit does a pretty good job to track the position, the GPS is not always working perfectly, and sometimes its behaviour is weird. Indeed, it is not “fit” to football, which require a specific type of tracking.

I think (or I hope) that new (cheap) connected objects will emerge to allow both professional & amateur football players to gather exhaustive statistics on their performance. Imagine a world where everybody would wore a connected object and you could “replay” the game afterward.

Those objets should be small and light enough that we could wear it while playing. I wore my watch to gather those data, but I think it is not allowed, as it could hurt other players. It should be almost invisible !

This would be a first step toward “Football science”, where we would better track our progress. Moreover, we would be able to attribute the outcome of a game to the performance of every players. Currently, the striker takes all the merit when he scores goals. While he is arguably one of the most important player in a team, we should be able to explain quantitatively how other players play a determinant role in a game. But this is a topic for another post.

Café Crème

Note: if you try to reproduce my code, don’t use Google Chrome for rendering, as it doesn’t accept “file://” to load data. Use Firefox or Safari instead for instance.

Thanks for reading me ! My name is Pierre Delarroqua and I am not an experienced writer. I will write several other posts like this in the coming weeks to become better at it.

!!! Update !!! — I made a new version of the app, using the very popular Strava platform. You can check it out here:

Simply connect with your Strava account and

  • Analyze your Heatmap
  • Replay the game

Any feedback is really appreciated, as I will continue to improve it. Thank you !

--

--

Pierre Delarroqua
Laces Out

Co-founder @ Vech | ex @Uber, decent football player