Mapping Your Google Location History with Python

Small map of my Google location history data in the San Francisco Bay Area, 2012-2016I recently wrote about visualizing my Foursquare check-in history and it inspired me to map my entire Google location history data – about 1.2 million GPS coordinates from my Android phone between 2012 and 2016. I used Python and its pandas, matplotlib, and basemap libraries. The Python code is available in this notebook in this GitHub repo, and it’s simple to re-use to visualize your own location history.

Just download your JSON file from Google then run the code. First I load the JSON file and parse the latitude, longitude, and timestamp with pandas. Then I map my worldwide data set:

Map of my Google location history data worldwide, 2012-2016

Python and basemap are great for quickly making attractive maps of large geospatial data sets. The map above shows all 1.2 million GPS points in my Google location history, with the Kavrayskiy VII map projection. Next, I define a transverse Mercator projection for California and plot a zoomed-in view of my location history:

Map of my Google GPS location history data in California, made with Python matplotlib basemap

You can see most of my time is spent around the Bay Area, with additional trips around and across California. Lake Tahoe is the little loop in Northern California along the border with Nevada, and Joshua Tree is the big loop east of Los Angeles. It would be nice if there were annotations, so let’s define a transverse Mercator projection centered on the San Francisco Bay Area and map an even more zoomed-in view of my location history:

Map of my Google GPS location history data in the San Francisco Bay Area of Northern California, made with Python matplotlib basemap

This map’s annotations for San Francisco, Berkeley, and San Jose are all done in pure Python. Check out the IPython notebook with my code in this GitHub repo and feel free to re-purpose it to map your own Google location history. You might also be interested in mapping everywhere you’ve ever been, analyzing your Foursquare check-in history, or our course at UC Berkeley that teaches these skills and tools.

2 thoughts on “Mapping Your Google Location History with Python”

Leave a Reply

Your email address will not be published. Required fields are marked *