Created
March 1, 2015 18:58
-
-
Save alexhanh/65b16b1c9966a73dd82f to your computer and use it in GitHub Desktop.
Analyzing Google location data https://maps.google.com/locationhistory/b/0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'haversine' | |
| require 'json' | |
| require 'time' | |
| require 'date' | |
| data = JSON.parse(File.read('LocationHistory.json')) | |
| jyvaskyla = [62.244747, 25.7472184] | |
| away_days = {} | |
| data['locations'].reverse.each do |location| | |
| time = Time.at(location['timestampMs'].to_i / 1e3) | |
| lat = location['latitudeE7'] / 1e7 | |
| lon = location['longitudeE7'] / 1e7 | |
| pos = [lat, lon] | |
| if Haversine.distance(pos, jyvaskyla).to_kilometers > 100.0 && time.year == 2014 | |
| away_days[time.to_date] = true | |
| end | |
| end | |
| puts away_days.keys.count |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: Get the JSON data from https://www.google.com/settings/takeout (choose only Location History)