DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

Cover image for How to generate a heat map from your google location data
Luka Steinbach
Luka Steinbach

Posted on

How to generate a heat map from your google location data

Introduction

It is known that Google tracks a lot of your data but many people don't know that you can actually download your data.

You can download your data here: https://takeout.google.com/

When I downloaded my location history I had a JSON file with about 14,000,000 lines and over 1,050,000 data points dating back to 2014.

Why not use this data?

The Script

So I wrote a Python script that generates a heat map from this data.

GitHub repo: github.com/luka1199/geo-heatmap

The results look like this:
Alt Text

To generate the heat map I used the Python library Folium, which internally uses Leaflet.js.

Instructions on how to use the script are in the README file of the repo or below.

Instructions

1. Install Python 3+

If you don't already have Python 3+ installed, grab it from https://www.python.org/downloads/. You'll want to download install the latest version of Python 3.x. As of 2019-11-22, that is Version 3.8.

2. Get Your Location Data

Here you can find out how to download your Google data: https://support.google.com/accounts/answer/3024190?hl=en
Here you can download all of the data that Google has stored on you: https://takeout.google.com/

To use this script, you only need to select and download your "Location History", which Google will provide to you as a JSON file by default. KML is also an output option and is accepted for this program.

You can also import GPS Exchange Format (GPX) files,
e.g. from a GPS tracker.

3. Clone The Repository

On https://github.com/luka1199/geo-heatmap, click the green "Clone or Download" button at the top right of the page. If you want to get started with this script more quickly, click the "Download ZIP" button, and extract the ZIP somewhere on your computer.

4. Install Dependencies

In a command prompt or Terminal window, navigate to the directory containing this repository's files. Then, type the following, and press enter:

pip install -r requirements.txt

5. Run The Script

In the same command prompt or Terminal window, type the following, and press enter:

python geo_heatmap.py <file> [<file> ...]

Replace the string <file> from above with the path to any of the following files:

  • The Location History.json JSON file from Google Takeout
  • The Location History.kml KML file from Google Takeout
  • The takeout-*.zip raw download from Google Takeout that contains either of the above files
  • A GPS Exchange Format (GPX) file

Top comments (0)

Let's Get Hacking

Join the DEV x Linode Hackathon 2022 and use your ingenuity and creativity to build using Linode.

β†’ Join the Hackathon <-