{"id":977,"date":"2016-06-05T22:27:21","date_gmt":"2016-06-06T05:27:21","guid":{"rendered":"http:\/\/www.certainly-strange.com\/?p=977"},"modified":"2016-07-11T12:18:22","modified_gmt":"2016-07-11T19:18:22","slug":"more-google-location-data","status":"publish","type":"post","link":"http:\/\/www.certainly-strange.com\/?p=977","title":{"rendered":"More Google Location Data"},"content":{"rendered":"<p>So I&#8217;ve been doing some more investigating of my Google Timeline Data here and there (as I started writing about <a href=\"http:\/\/www.certainly-strange.com\/?p=968\">here<\/a>).<\/p>\n<p>After my last post, a friend of mine pointed me towards the <a href=\"http:\/\/www.movable-type.co.uk\/scripts\/latlong.html\">Haversine formula<\/a> for calculating distance between two sets of lat, long coordinates and with that I was able to calculate distances on a day-by-day basis that were consistently close to Google&#8217;s estimations for the days. Encouraged, I then moved on to calculating distances on a per-year basis, and that was fun. I got what seemed reasonable to me:<\/p>\n<p>Between 5\/22\/15 and 5\/22\/16 I went 20,505 miles<\/p>\n<p>Between 9\/20\/2013 and 5\/22\/16 I went 43,434 miles<\/p>\n<p>Recall that these are for every sort of movement, including airplanes. So you can see my average miles\/day went way up recently, due to a few big recent airplane trips. So if the numbers seem high (~60 miles a day, ~45 miles a day), this is why.<\/p>\n<p>But then I wanted to visualize some of the data. I decided to use matplotlib to plot the points because it is easy to use and because Python has an easy way to load JSON data.<\/p>\n<p>So I ended up breaking down the points by the assigned &#8220;activity.&#8221; True to my word, I only considered the &#8220;highest likelihood activities,&#8221; and discarded all the other less likely ones. To keep it simple.<\/p>\n<p>You may recall that I had a total of 1,048,575 position data points. Well, only 288,922 had activities assigned to them. So just over a quarter. Still, it is enough data to have a bit of fun with.<\/p>\n<p>Of those 288,922 data points with activity, it turns out that there were only a total of 7 different activities:<\/p>\n<p>still<br \/>\nunknown<br \/>\nonBicycle<br \/>\nonFoot<br \/>\ntilting<br \/>\ninVehicle<br \/>\nexitingVehicle<\/p>\n<p>The first obvious thing to do was to sort by activity type and then plot the\u00a0 coordinates segregated by activity type.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-theme=\"twilight\" data-enlighter-language=\"python\">import\u00a0numpy\u00a0as\u00a0np\r\nimport\u00a0matplotlib.pyplot\u00a0as\u00a0plt\r\nfrom\u00a0mpl_toolkits.basemap\u00a0import\u00a0Basemap\r\nimport\u00a0csv\r\n\r\nlatitudeArray\u00a0=\u00a0[]\r\nlongitudeArray\u00a0=\u00a0[]\r\n\r\nwith\u00a0open(\"bicycle.csv\")\u00a0as\u00a0csvfile:\r\n\u00a0\u00a0\u00a0\u00a0reader\u00a0=\u00a0csv.reader(csvfile)\r\n\u00a0\u00a0\u00a0\u00a0for\u00a0row\u00a0in\u00a0reader:\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0x,\u00a0y\u00a0=\u00a0float(row[0]),\u00a0float(row[1])\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0latitudeArray.append(x)\u00a0#storing\u00a0all\u00a0the\u00a0latitudes\u00a0and\u00a0longitudes\u00a0in\u00a0separate\u00a0arrays,\u00a0but\u00a0the\u00a0index\u00a0is\u00a0the\u00a0same\u00a0for\u00a0each\u00a0pair\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0longitudeArray.append(y)\r\n\r\nm\u00a0=\u00a0Basemap(llcrnrlon=min(longitudeArray)-10,\u00a0#Set\u00a0map's\u00a0displayed\u00a0max\/min\u00a0based\u00a0on\u00a0your\u00a0set's\u00a0max\/min\r\n\u00a0\u00a0\u00a0\u00a0llcrnrlat=min(latitudeArray)-10,\r\n\u00a0\u00a0\u00a0\u00a0urcrnrlon=max(longitudeArray)+10,\r\n\u00a0\u00a0\u00a0\u00a0urcrnrlat=max(latitudeArray)+10,\r\n\u00a0\u00a0\u00a0\u00a0lat_ts=20,\u00a0#\"latitude\u00a0of\u00a0true\u00a0scale\"\u00a0lat_ts=0\u00a0is\u00a0stereographic\u00a0projection\r\n\u00a0\u00a0\u00a0\u00a0resolution='h',\u00a0#resolution\u00a0can\u00a0be\u00a0set\u00a0to\u00a0'c','l','i','h',\u00a0or\u00a0'f'\u00a0-\u00a0for\u00a0crude,\u00a0low,\u00a0intermediate,\u00a0high,\u00a0or\u00a0full\r\n\u00a0\u00a0\u00a0\u00a0projection='merc',\r\n\u00a0\u00a0\u00a0\u00a0lon_0=longitudeArray[0],\r\n\u00a0\u00a0\u00a0\u00a0lat_0=latitudeArray[0])\r\n\r\nx1,\u00a0y1\u00a0=\u00a0m(longitudeArray,\u00a0latitudeArray)\u00a0#map\u00a0the\u00a0lat,\u00a0long\u00a0arrays\u00a0to\u00a0x,\u00a0y\u00a0coordinate\u00a0pairs\r\n\r\nm.drawmapboundary(fill_color=\"white\")\r\nm.drawcoastlines()\r\nm.drawcountries()\r\n\r\nm.scatter(x1,\u00a0y1,\u00a0s=25,\u00a0c='r',\u00a0marker=\"o\")\u00a0#Plot\u00a0your\u00a0markers\u00a0and\u00a0pick\u00a0their\u00a0size,\u00a0color,\u00a0and\u00a0shape\r\n\r\nplt.title(\"Steen's\u00a0Bicycling\u00a0Coordinates\")\r\n\r\nplt.show()<\/pre>\n<p>Note that, at the time, I wrote a script which saved all the different activity types into their own CSV, because I wanted to look at them and play with them individually. And I then decided to load these CSV files into my script for plotting &#8211; because they were there. Note that, if I went back and did it again, I&#8217;d probably not bother with the CSV intermediary, and just go straight from the geoJSON file.<\/p>\n<p>And in this way I was able to see the different activities plotted onto Basemap&#8217;s default map thing:<\/p>\n<figure id=\"attachment_978\" aria-describedby=\"caption-attachment-978\" style=\"width: 812px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/steen-biking03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-978 size-full\" src=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/steen-biking03.png\" alt=\"steen-biking03\" width=\"812\" height=\"612\" srcset=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/steen-biking03.png 812w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/steen-biking03-300x226.png 300w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/steen-biking03-768x579.png 768w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-978\" class=\"wp-caption-text\">Points in San Francisco from my Timeline Data that Google tagged as &#8220;onBicycle.&#8221; I can see a lot of my favorite biking routes, as well as that time I biked the Golden Gate Bridge.<\/figcaption><\/figure>\n<figure id=\"attachment_980\" aria-describedby=\"caption-attachment-980\" style=\"width: 640px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-980 size-large\" src=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06-1024x559.png\" alt=\"onfoot06\" width=\"640\" height=\"349\" srcset=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06-1024x559.png 1024w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06-300x164.png 300w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06-768x419.png 768w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/onfoot06.png 1626w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-980\" class=\"wp-caption-text\">Points in San Francisco from my Timeline Data that Google tagged as &#8220;onFoot.&#8221; Streets are less clear, and it sort of looks like a big blob centered around the Mission. Which seems accurate, given that I just sort of meander about. The one straight looks like Market, which I occasionally will walk all the way on, so that makes sense.<\/figcaption><\/figure>\n<figure id=\"attachment_981\" aria-describedby=\"caption-attachment-981\" style=\"width: 640px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03.png\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-981 size-large\" src=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03-1024x559.png\" alt=\"invehicle03\" width=\"640\" height=\"349\" srcset=\"http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03-1024x559.png 1024w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03-300x164.png 300w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03-768x419.png 768w, http:\/\/www.certainly-strange.com\/wp-content\/uploads\/2016\/06\/invehicle03.png 1626w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 984px) 61vw, (max-width: 1362px) 45vw, 600px\" \/><\/a><figcaption id=\"caption-attachment-981\" class=\"wp-caption-text\">Points in San Francisco from my Timeline Data that Google tagged as &#8220;inVehicle.&#8221; All the points in the bay are most likely due to when I take the ferry to work &#8211; as a ferry is, in fact, a vehicle. And I am not surprised to see that the vast majority of the points appear to be on Van Ness.<\/figcaption><\/figure>\n<p>I also plotted the other categories &#8211; including the mysterious &#8220;tilting,&#8221; but I couldn&#8217;t really discern any sort of meaning from those. They just looked like all the points from everywhere I&#8217;ve ever been, and were therefore not very meaningful. Not like the dramatic differences between the points and obvious routes for biking, on any sort of vehicle, or walking. So, there&#8217;s no need for you to see those.<\/p>\n<p>I&#8217;d say this was a success. So my next question is to figure out how much time I spend doing each activity. And how much time I spend in each place. I&#8217;ll have to think about it a bit on how to calculate the time. All those points with no activity associated with them have me concerned that it won&#8217;t be very straightforward to just subtract the timestamps to get <span class=\"_Tgc\">\u0394T<\/span>. It could be the case that in the &#8220;no activity&#8221; points, I had ended up doing completely different things, and then returned to the original activity (in which case the calculated <span class=\"_Tgc\">\u0394T<\/span> would be incorrect). But, then again, it is probably very likely that all those &#8220;no activity&#8221; points actually are the same activity if they are bookended by it. Hmm.<\/p>\n<p>So now I&#8217;m wondering if, given that a time point is uploaded every 60 seconds, I should just say 1 timepoint = 60 seconds? That doesn&#8217;t seem quite right to me, but I&#8217;ll work it out for a smaller data set and see if that even comes close to accurate. I&#8217;ll keep thinking about it, but if anybody has any suggestions on how to get around this problem, feel free to let me know!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So I&#8217;ve been doing some more investigating of my Google Timeline Data here and there (as I started writing about here). After my last post, a friend of mine pointed me towards the Haversine formula for calculating distance between two sets of lat, long coordinates and with that I was able to calculate distances on &hellip; <a href=\"http:\/\/www.certainly-strange.com\/?p=977\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;More Google Location Data&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[364,361,363],"tags":[],"class_list":["post-977","post","type-post","status-publish","format-standard","hentry","category-json","category-programming","category-python"],"_links":{"self":[{"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/posts\/977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=977"}],"version-history":[{"count":7,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/posts\/977\/revisions"}],"predecessor-version":[{"id":1054,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=\/wp\/v2\/posts\/977\/revisions\/1054"}],"wp:attachment":[{"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=977"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.certainly-strange.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}