

Map Your Google Location History - wormold
http://nbviewer.ipython.org/github/chrisalbon/code_py/blob/master/matplotlib_map_your_google_data.ipynb

======
tghw
For those who don't want to do it themselves:
[https://maps.google.com/locationhistory/b/0](https://maps.google.com/locationhistory/b/0)

~~~
markveronda
Actually, the Google-provided version restricts you to only 30 days. If you're
interested in everywhere you have been, ever (according to Google), then this
is quite awesome and you get much more options with _how_ you display that
data and what else you can incorporate with it.

~~~
thekos
You can go back further by modifying the startTime parameter in the download
link.

[https://maps.google.com/locationhistory/b/0/kml?startTime=14...](https://maps.google.com/locationhistory/b/0/kml?startTime=1400003200000&endTime=1410159600000)

~~~
jacquesm
Oh my, a hacker. Better be careful.

[http://theblot.com/man-jailed-because-feds-dont-
understand-c...](http://theblot.com/man-jailed-because-feds-dont-understand-
computer-hacking-7717221)

------
Tiksi
I did something similar with that data a few months ago using qGIS, postGIS,
and OSM data:

[https://packetfire.org/projects/qgis/img/lines.crop.png](https://packetfire.org/projects/qgis/img/lines.crop.png)

[https://packetfire.org/projects/qgis/img/points.and.lines.cr...](https://packetfire.org/projects/qgis/img/points.and.lines.crop.png)

[https://packetfire.org/projects/qgis/img/too.many.points.png](https://packetfire.org/projects/qgis/img/too.many.points.png)

The data is definitely not completely consistent. Trips I took are missing,
even though Google plus made auto-awesome stories with pictures taken there,
and got the locations correct in those. There are also some points that
shouldn't be there. It shows me in Michigan a few separate times (a few
hundred data points at various times), to which I've never been. It also puts
me at 0 Lat/0 Long a few times, but the reason for this is pretty obvious,
just confusing when I first saw it mapped. Also there's quite a bit of
"teleporting" from location to location, even though I had my phone with me
and was using it when I was traveling between them.

The third image, on the other hand, is seemingly way too much data at one
place. It's my workplace at 1 meter resolution. You'd think they could merge
it down to a few points a day at the most, but for whatever reason, there are
on average 200 points per day there. It just astonishes me how much data there
is at some places, yet in others massive chunks seem to be missing.

I started working on a write up of how I did all this, including the bash
scripts I wrote to parse, clean and transform the data, but one thing came up
after another, and I haven't gotten around to finishing it. If anyone is
interested, I'll finish that up and post it this week. I still have to finish
up my scripts to clean the data of the "teleporting" and the places I haven't
actually been. It was definitely a fun project, and now I have an interactive
map of (some of) my past travels and habits. qGIS was interesting to play
with, learning bits as I went along trying to get it to display properly and
actually render what I wanted to see. Definitely gave me a new level of
respect for anyone that does cartography.

~~~
Bassetts
I have messed around with mapping my location history and had some similar
problems. Apparently I have been to Essex, UK although I have never been there
in my life.

I tracked down the teleporting problem to the fact my tablet was at home and
turned on. It seems you can't set location reporting per device, it is either
on or off, so you end up being in two locations at once. I was going to look
in to trying to remove problem points be setting a distance or speed
threshold. That brings the problem of knowing which data point to keep and
which to drop though, which I have not got a solution for yet apart from
requiring user interaction.

~~~
Tiksi
In my case, my phone is the only device should report location data, and the
times on either side of the teleport were correct, it just seems to be missing
the trip itself. As far as removing the points, there seem to be plenty of
points at the a similar time and location, so removing either one wouldn't be
an issue. However it's currently one continuous track, and removing a point
would break that.

My idea was to use speed as the constraint, give the points on both sides a
label, and have the line between them be transparent. I just need to figure
out that last part.

------
edent
If you want to get your data programatically, Google do _not_ provide an API.

You'll need to "borrow" your own cookies. I documented the process at
[http://shkspr.mobi/blog/2014/04/extracting-your-own-
location...](http://shkspr.mobi/blog/2014/04/extracting-your-own-location-
information-from-google-the-hard-way/)

~~~
dochtman
You can just use Google Takeout, IIRC.

~~~
edent
Takeout does not provide an API.

------
sahaskatta
I used a heatmap API with 2+ years worth of Google Location History data to
make this last year:
[https://plus.google.com/+sahaskatta/posts/5bbn9D9ZzuP](https://plus.google.com/+sahaskatta/posts/5bbn9D9ZzuP)

~~~
IneffablePigeon
This inspired me to do the same. If anyone wants to try, I put my
implementation up on github:
[https://github.com/olane/locationheatmap](https://github.com/olane/locationheatmap)

------
dochtman
I built my own version of this about two years ago:

[https://dirkjan.ochtman.nl/writing/2012/11/28/tracing-a-
path...](https://dirkjan.ochtman.nl/writing/2012/11/28/tracing-a-path.html)

Python code available here:
[https://github.com/djc/galatna](https://github.com/djc/galatna)

------
acadien
Very cool script! I just tried it out myself and it seems that Google's
location history is actually really spotty. It missed several of my trips
(during which the phone was active and responsive) and it also included some
spots that I've never been to. I double checked the JSON and the problem is on
Google's end and not the script.

------
ChrisArchitect
I've done this before by just downloading location history as KML and then
hosting somewhere and directing google maps at it in an embed etc. works fine.

------
shaurz
So apparently I've been to Hong Kong... first I've heard of it. Also there
seems to be no record of my visit to Canada last year.

------
dzhiurgis
Am I the only one whose location data is missing?

~~~
icebraining
Maybe you've disabled the feature?

[https://support.google.com/gmm/answer/3118687?hl=en](https://support.google.com/gmm/answer/3118687?hl=en)

------
dalek2point3
how does python know what map data to use?

~~~
markveronda
It's fed in by the JSON file that was downloaded in Step 1 from Google when
you request an archive of your data.

From the site: # Create a dataframe from the json file in the filepath raw =
pd.io.json.read_json('/Users/chrisralbon/Downloads/Location
History/LocationHistory.json')

