Jekyll2023-11-05T23:56:56+00:00https://olemeyer.de/feed.xmlOle MeyerA personal blog focused on Tinkering, Machine Learning and much more.Ole MeyerAnniversary Heatmaps2021-11-09T00:00:00+00:002021-11-09T00:00:00+00:00https://olemeyer.de/21/313/heatmaps-overview<h1 id="background-getting-data-from-google">Background: Getting Data from Google</h1>
<p>Most people today will probably be aware that Google, like many other tech giants, collects large amounts of data about its users. However, what many people probably don’t know, is that Google allows its users to download all the data associated to their accounts as an archive file. This can be done using Google’s <a href="https://takeout.google.com/">Takeout Service</a>.</p>
<p>Quite some time ago, when the local anti-corona measures were strictest and there wasn’t much else to do, I requested my full data to search for potentially interesting insights about myself, hidden between the millions of data points stored about me.<sup id="fnref:1" role="doc-noteref"><a href="#fn:1" class="footnote" rel="footnote">1</a></sup></p>
<p>For the little project that will be described in this post, one file in the exported archive will be of particular interest: <em>LocationHistory.json</em>. As the file name already suggests, this file contains most of the information Google has about where I (or more accurately my phone) have been in the past years. And let me tell you: It’s <em>a lot</em> of information. 1.963.756 geo-positions, to be precise.<sup id="fnref:2" role="doc-noteref"><a href="#fn:2" class="footnote" rel="footnote">2</a></sup></p>
<h1 id="turning-the-data-into-a-gift">Turning the Data into a Gift</h1>
<h2 id="the-idea">The Idea</h2>
<p>At the same time I rummaged through my exported data, I was on the lookout for a nice, personal anniversary gift for my girlfriend. At some point it dawned on me, that these two undertakings could probably be combined nicely.</p>
<p>After some brainstorming I settled on the idea of creating visualizations of our first dates, combine them into a collage and to frame them. For the visualization I decided to use heatmaps.</p>
<h2 id="the-execution">The Execution</h2>
<p>To create the heatmaps I used Python. For easier handling, I first loaded the <em>LocationHistory.json</em> file into a <a href="https://github.com/pandas-dev/pandas">pandas</a> dataframe. I then wrote a little <a href="https://github.com/python-visualization/folium">folium</a>-based script, which takes the dataframe, a user specified time frame and some design parameters as inputs and outputs an interactive heatmap of the geo-positions collected in that timeframe. This output looks something like this<sup id="fnref:3" role="doc-noteref"><a href="#fn:3" class="footnote" rel="footnote">3</a></sup>:</p>
<iframe src="/assets/html/2021-11-09-heatmaps-overview/heatmap.html" height="450px" width="100%" style="border:none;"></iframe>
<p>After some fine-tuning on the map design - most notably switching to <a href="http://maps.stamen.com/#toner/">Stamen Toner</a> map tiles - I exported the maps of our first three dates as images. Using a graphics editor, these were then combined into a final collage, which was subsequently printed and framed. The end result looked something like this:</p>
<p><img src="/assets/images/2021-11-09-heatmaps-overview/banner.jpg" alt="A mockup of the final framed poster." title="A mockup of the final framed poster." /></p>
<h1 id="the-code">The Code</h1>
<p>I haven’t made the code publicly available yet, as it is a bit messy and not well documented. However, if I can find the time, I will tidy it up a bit, make it available via GitHub and write another short post to explain it in more detail. :relieved:</p>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:1" role="doc-endnote">
<p>More on this endeavor maybe later, in a separate post. <a href="#fnref:1" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:2" role="doc-endnote">
<p>Which is not really surprising to me as I’m an active user of Google Maps’s <a href="https://timeline.google.com/">Timeline</a> feature and have <a href="https://support.google.com/accounts/answer/3118687?hl=en">Location History</a> turned on for years. <a href="#fnref:2" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:3" role="doc-endnote">
<p>Thanks to Rob Williams for providing <a href="https://jayrobwilliams.com/posts/2020/09/jekyll-html">this nice guide</a> on how to make Leaflet maps work with Jekyll. <a href="#fnref:3" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Ole MeyerHow I turned my Google Location History into a beautiful Anniversary Gift.