Skip to content

Instantly share code, notes, and snippets.

@dgl
Created April 17, 2019 18:37
Show Gist options
  • Save dgl/5f06529c3460af9ff70adda9c168ed90 to your computer and use it in GitHub Desktop.
Save dgl/5f06529c3460af9ff70adda9c168ed90 to your computer and use it in GitHub Desktop.
Google Location History takeout
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Google's location history takeout data\n",
"\n",
"Currently downloads are returning something like:\n",
"\n",
" {\n",
" [...]\n",
" \"latitudeE7\" : 4010772801,\n",
" \"longitudeE7\" : 1454104378,\n",
" [...]\n",
" }\n",
" \n",
" In particular you're supposed to divide by 1e7:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"401.0772801"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"4010772801 / 1e7"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Not quite.\n",
"\n",
"After wondering if this was some special coordinate system but everyone on the internet just saying the \"E7\" was the clue I decided it was broken. \n",
"\n",
"It turns out they're returning signed values as unsigned..."
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[-284194495, 1454104378]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x = [4010772801, 1454104378].pack(\"LL\").unpack(\"ll\")"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"[-28.4194495, 145.4104378]"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(lat, lon) = x.map { |x| x / 1e7 }"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"https://www.openstreetmap.org/#map=9/-28.4194495/145.4104378"
]
}
],
"source": [
"print \"https://www.openstreetmap.org/#map=5/\" + lat.to_s + \"/\" + lon.to_s"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Ruby 2.6.2",
"language": "ruby",
"name": "ruby"
},
"language_info": {
"file_extension": ".rb",
"mimetype": "application/x-ruby",
"name": "ruby",
"version": "2.6.2"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"toc_cell": false,
"toc_position": {},
"toc_section_display": "block",
"toc_window_display": false
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment