2014 Location History

Keywords: Python, D3, JSON, GeoJSON

After reading Tyler Hartley's Visualizing My Location History with Python, Shapely, and Basemap post, I was curious to explore my own location data. With the new year upon us, I decided to take a look back at my whereabouts in 2014.

Because I have Google's Location History turned on, there is a record of all the places my phone's been. Users are able to download their location history, with latitude and longitude values, as well as data from several of Google's other products, using a service called Takeout. My location history was stored in a JSON file that I could process using Python.

With that, I loaded my data into a Pandas DataFrame, keeping just the 451,092 observations for 2014. According to Tyler's blog post, GPS location data is sent to Google once every 60 seconds. This is dependent on the device being on and in an area with mobile network reception. My data represents about 86% of the minutes in 2014. If you're curious, take a look at the IPython Notebook that includes the code to process the data.

The first approach I considered was plotting the coordinates on a Leaflet map. However, with the number of data points in my 2014 file, that was going to be problematic. I took a random sample of 20,000 points. Still, the performance of that map suffered due to the number of points needing to be rendered.

In addition to the choropleth map, Tyler shows a hexbin map of his location history. Binning is a way to reduce the number data points by aggregation. For more on hexbins, see indiemaps' blog post. So, I set out to find a way to create a hexbin layer on my Leaflet map. Luckily, I came across Ryan Blace's Leaflet D3 Plugin. What's great about Ryan's work is that it "leverages the data-binding power of D3 to allow you to dynamically update the data and visualize the transitions."

Click "Load data" to populate the map.1
1The data has been scrubbed to make it less obvious where I live.
Load data

The coordinates are aggregated within each hexagon, with the darker bins representing more data points. As the map is zoomed, the hexbins change to reflect the area they cover. Try zooming out to see the extent of where I've been.

This visualization maps my memories, in a way. It reminds me of the various places I visited in the past year. It does so without the problems associated with plotting every data point. For example, I'm reminded of the time my family and I went to the San Francisco Zoo in early 2014. I also see the Berkeley Kite Festival. I see the import.io Data Summit event at Dogpatch Studios that a few of my classmates and I attended. There are various others. This map helps me fondly look back on 2014.

A big thanks to Tyler and Ryan for their work, which inspired me to create this visualization. This is my first experience using D3 and am looking forward to my next project.