Posted by & filed under Android, Web Development.

I’ve always been one for displaying data in various different ways, today I’ve been messing around with the location data Google stores from my mobile phone.

The ability to display this data came from /u/snowstorm99 (original thread), snowstorm99 put together a handy guide on to how to make this yourself, however after running through this myself I found a few issues with it. I thought I’d write my own guide on how to create it for an absolute beginner.

Josh's Location Data

Creating Your Own Location Map

  1. First of all you are going to need to install the Python language onto your computer. Version 2.7.8 appears to work well with this so grab the download from here: https://www.python.org/download/releases/2.7.8/
    I would strongly suggest installing Python directly to your C Drive (C:\Python27), I originally had my installation elsewhere and it appeared to cause problems.
  2. Secondly you will need to install PIL (Python Imaging Library). Later versions of Python already come packaged with PIL, but I’m not sure if they work with the code we are going to later on. Feel free to try out and comment below if you find success. When you run the installer, it should pick up on where you have installed Python. I’d suggest leaving everything as default.
  3. Download the “LatitudePlot.py” file from here:  https://github.com/snowdonjames/LatitudeHistoryPlotter
  4. Download the “location_history_json_converter.py” file from here: https://github.com/Scarygami/location-history-json-converter
  5. Now to download the map that you’re going to be plotting your data on. I’ve uploaded a copy of a UK map to here: http://stuff.joshjordan.co.uk/ImageAndData.zip
    If you’re front outside the UK then you’ll need to find a map of the area you’d like to use. I can’t just be any old map though you need to have the Image data that goes with it.
  6. Now to download you’re location data, this is the last download I swear! Head on over to Google Takeout: https://www.google.com/settings/takeout. Make sure you’re signed in to your google account and just select ‘Location History’. Once this is downloaded you’re good to go!
  7. Create a new folder in the directory that you installed Python in, for me it was as follows: C:\Python27\Location (I created the Location folder).
  8. Copy all the files you downloaded into that folder. Make sure to extract all of the files form the zip folder that you have into this location as well.
  9. Hold the shift key and right click in the Location folder, click “Open command window here”
  10. Copy in the following: “location_history_json_converter.py LocationHistory.json LocationHistory.kml” and press enter. Now depending on how much location data you have, this may take a while.  For me it only took around 30 seconds. The speed will also depend on how fast your computer is, so be patient if you’re running on an old system!
  11. You should now see a file called LocationHistory.kml. If not try re-running the the above command again.
  12. Now type the following into the command window: “LocationHistoryPlotter.py”.  You should see something like below, this will go on for a bit.
    Latitude History Plotter example output
  13. Once the above has completed running, you should find another new file has appeared (try pressing F5 to refresh if it hasn’t). The file should be called “LatitudeData.png”. This file should contain a map with lines drawn all over it. Red lines indicate most recent data, yellow lines indicate older data.

Summary

Hopefully you’ve been able to follow the guide through and have yourself a visual representation of your location data. If you’ve run into any issues along the way, feel free to leave a comment and I’ll try to help out where I can. The most common problem I find is that your computer may need to be restarted after step 2. This is because Python adds data into your Windows Environment Path variable, which doesn’t work until you restart explorer.exe and the easiest way for most people to do that is a restart.

If this is too technical for you and you just want to see a map with your location data on it now, then head on over to here: https://maps.google.co.uk/locationhistory. It only displays your last 30 days of data, and doesn’t look quite as nice. But it’s something!

One Response to “Visualising Your Phones Location Data”

  1. Hannah Nicklin

    You’re a brilliant writer! Very thorough step by step instructions, although I think I’d still manage to blow up my computer if I attempted this! Hahaha! Please do more tutorials!!

Leave a Reply

You must be logged in to post a comment.