This is a script that generates an interactive geo heatmap from your Google location history data using Python, Folium and OpenStreetMap.
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.
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.
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.
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
In the same command prompt or Terminal window, type the following, and press enter:
python geo_heatmap.py <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
usage: geo_heatmap.py [-h] [-o] [--min-date YYYY-MM-DD]
[--max-date YYYY-MM-DD] [-s] [--map MAP]
file [file ...]
positional arguments:
file Any of the following files:
1. Your location history JSON file from Google Takeout
2. Your location history KML file from Google Takeout
3. The takeout-*.zip raw download from Google Takeout
that contains either of the above files
optional arguments:
-h, --help show this help message and exit
-o , --output Path of heatmap HTML output file.
--min-date YYYY-MM-DD
The earliest date from which you want to see data in the heatmap.
--max-date YYYY-MM-DD
The latest date from which you want to see data in the heatmap.
-s, --stream Option to iterativly load data.
--map MAP, -m MAP The name of the map tiles you want to use.
(e.g. 'OpenStreetMap', 'Stamen Terrain', 'Stamen Toner')
The script will generate a HTML file named heatmap.html
. This file will automatically open in your browser once the script completes. Enjoy!
Your LocationHistory.json
file is probably huge, and Python is running out of memory when the script tries to parse that file.
To fix this, download and install the 64-bit version of Python. To do this:
- Go to python.org.
- Click the link corresponding to your OS next to "Looking for Python with a different OS?"
- Click the "Latest Python 3 Release" link.
- Scroll down to "Files".
- Click to download the x64 release. For example, on Windows, that's the "Windows x86-64 executable installer" link.
- Install!
If this does not fix the issue you can use the stream option:
python geo_heatmap.py -s <file>
This will be slower but will use much less memory to load your location data.
I'm getting a SyntaxError
when running pip install -r requirements.txt
or python geo_heatmap.py <file>
. What am I doing wrong?
You are probably using the python interpreter to run these commands. Try to run them in cmd.exe or Windows PowerShell (Windows) or the Terminal (Linux, MacOS).
I'm getting the error message TypeError: __init__() got an unexpected keyword argument 'max_value'
. What can I do to fix this?
Try to run:
pip uninstall progressbar
pip install progressbar2
You probably have progressbar installed, which uses maxval
as an argument for __init__
. Progressbar2 uses max_value
.
Yes! Run the script like this:
python geo_heatmap.py <file1> <file2> <file3> ...
Examples:
python geo_heatmap.py locations1.json locations2.json
python geo_heatmap.py locations.json locations.kml takeout.zip
You can add as many files as you want.