plot-google-location-history.ipynb
Take a Google Location History archive and plot where you've been, how fast you moved and how much data was collected. Looking for contributors that'll extend this notebook to make more cool stuff!
Please log in to comment.I get an error on line json_data <- fromJSON(txt=temp) :(
This notebook requires you to use the Google Location History upload to get your GPS data into Open Humans.
This notebook then uses the GPS data to plot your personal movement history on different maps on different scales.
For a start let's load our required packages. To load the JSON we are using rjson
, which needs to be installed with install.packages
in the first step:
With that out of the way we can access our Google Location History data from our Open Humans account:
Now that we have our fitbit data stored in json_data
we can start to work with that data. Much of this notebook is adapted code from Shirin Glander's excellent blogpost.
Let's read the location data in to the loc
variable and properly parse the timestamps of when we have been at a place and convert the E7 formatted coordinates to regular coordinates:
Now we can look at how our data looks like:
Now that we have collected and formatted the data we can start analyzing it!
Let's start off to see how much data Google has about my location? After some more data processing we want to plot:
There's some variation in the amount of data Google recorded for each time unit, but nevertheless it seems to come out at around 50 data points per day on average. This probably also depends on how much we travel, the more we are traveling, the more data can be collected.
Google gives an estimation on how accurate the data is it recorded about our location. Let's plot how accurate that data is:
Overall the accuracy of the data is pretty good and the vast majority of the data points is in the smallest error category. Then there are some outliers of data being less accurate, but that's only a small amount overall.
We will start by looking at a world map and plot each of the data points that Google has. This gives us a good indication of where we have been and where we might want to zoom in more:
In my case Central Europe is more or less one huge red blob. Which makes sense given that I have been commuting between Frankfurt, Germany and Zurich, Switzerland for quite some time. So let's zoom in on this part of the world.
To do so we have to define some boundary boxes through latitudes & longitudes. This can be done by the variables below. If you want to zoom in onto another part of the World: Adjust these four variables to map down to the location you are interested in. (Googling: coordinates PLACE_OF_INTEREST
is really useful for this)
With this out of the way we can start the plotting with the code below. And to make it a bit more interesting we are not just plotting the points, but also the velocity we had at the time the data was recorded. That way we can see where we moved fast & slow.
The blue spots (e.g. around Frankfurt in the center of the map and around Zurich in the South) show where I moved rather slowly, i.e. on foot. Between these we can see the more purpleish connections, which are me driving on the highways.
Let's now zoom in some more on my movements in and around Frankfurt, where I lived for a good while. We again define our boundary box through the four cutoff-latitude/longitudes. Adjust these again if you want to zoom in on another place:
Now we can do the same plot as before but zoomed in at a given place: