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:
Updating HTML index of packages in '.Library' Making 'packages.html' ... done Attaching package: ‘lubridate’ The following object is masked from ‘package:base’: date Attaching package: ‘zoo’ The following objects are masked from ‘package:base’: as.Date, as.Date.numeric Warning message: “`panel.margin` is deprecated. Please use `panel.spacing` property instead”
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:
Warning message: “`panel.margin` is deprecated. Please use `panel.spacing` property instead”`stat_bin()` using `bins = 30`. Pick better value with `binwidth`. Warning message: “Removed 482 rows containing non-finite values (stat_bin).”
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:
Map from URL : http://tile.stamen.com/toner/2/0/0.png Map from URL : http://tile.stamen.com/toner/2/1/0.png Map from URL : http://tile.stamen.com/toner/2/2/0.png Map from URL : http://tile.stamen.com/toner/2/3/0.png Map from URL : http://tile.stamen.com/toner/2/0/1.png Map from URL : http://tile.stamen.com/toner/2/1/1.png Map from URL : http://tile.stamen.com/toner/2/2/1.png Map from URL : http://tile.stamen.com/toner/2/3/1.png Map from URL : http://tile.stamen.com/toner/2/0/2.png Map from URL : http://tile.stamen.com/toner/2/1/2.png Map from URL : http://tile.stamen.com/toner/2/2/2.png Map from URL : http://tile.stamen.com/toner/2/3/2.png
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.
Map from URL : http://tile.stamen.com/toner/7/65/41.png Map from URL : http://tile.stamen.com/toner/7/66/41.png Map from URL : http://tile.stamen.com/toner/7/67/41.png Map from URL : http://tile.stamen.com/toner/7/68/41.png Map from URL : http://tile.stamen.com/toner/7/65/42.png Map from URL : http://tile.stamen.com/toner/7/66/42.png Map from URL : http://tile.stamen.com/toner/7/67/42.png Map from URL : http://tile.stamen.com/toner/7/68/42.png Map from URL : http://tile.stamen.com/toner/7/65/43.png Map from URL : http://tile.stamen.com/toner/7/66/43.png Map from URL : http://tile.stamen.com/toner/7/67/43.png Map from URL : http://tile.stamen.com/toner/7/68/43.png Map from URL : http://tile.stamen.com/toner/7/65/44.png Map from URL : http://tile.stamen.com/toner/7/66/44.png Map from URL : http://tile.stamen.com/toner/7/67/44.png Map from URL : http://tile.stamen.com/toner/7/68/44.png Map from URL : http://tile.stamen.com/toner/7/65/45.png Map from URL : http://tile.stamen.com/toner/7/66/45.png Map from URL : http://tile.stamen.com/toner/7/67/45.png Map from URL : http://tile.stamen.com/toner/7/68/45.png Map from URL : http://tile.stamen.com/toner/7/65/46.png Map from URL : http://tile.stamen.com/toner/7/66/46.png Map from URL : http://tile.stamen.com/toner/7/67/46.png Map from URL : http://tile.stamen.com/toner/7/68/46.png
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:
Map from URL : http://tile.stamen.com/toner/12/2145/1385.png Map from URL : http://tile.stamen.com/toner/12/2146/1385.png Map from URL : http://tile.stamen.com/toner/12/2147/1385.png Map from URL : http://tile.stamen.com/toner/12/2148/1385.png Map from URL : http://tile.stamen.com/toner/12/2145/1386.png Map from URL : http://tile.stamen.com/toner/12/2146/1386.png Map from URL : http://tile.stamen.com/toner/12/2147/1386.png Map from URL : http://tile.stamen.com/toner/12/2148/1386.png Map from URL : http://tile.stamen.com/toner/12/2145/1387.png Map from URL : http://tile.stamen.com/toner/12/2146/1387.png Map from URL : http://tile.stamen.com/toner/12/2147/1387.png Map from URL : http://tile.stamen.com/toner/12/2148/1387.png