• Stars
    star
    455
  • Rank 93,766 (Top 2 %)
  • Language
    Python
  • License
    Apache License 2.0
  • Created over 11 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert the Location History JSON File from Google Takeout into a useable format

Location History JSON Converter

This Python script takes the JSON file of your location history which you can get via Google Takeout and converts it into other formats.

Requirements

  • Install python (3.2+) if you don't have it installed already.

  • Download the python script by either cloning this repository (git clone https://github.com/Scarygami/location-history-json-converter) or downloading the script file.

  • Install dependencies using pip install -r requirements.txt

    See below if you encounter issues installing the Shapely package

  • Request your location history via Google Takeout and once the package is ready, download and unzip it.

    I find it easiest to place the Location History.json in the same folder where the script is located.

Usage

python location_history_json_converter.py input output [-h] [-f {format, see below}]

input                Input File (Location History.json)
output               Output File (will be overwritten!)

optional arguments:
  -h, --help                             Show this help message and exit
  -f, --format {format, see below}       Format of the output
  -i, --iterative                        Loads the JSON file iteratively
  -s, --startdate STARTDATE              The Start Date - format YYYY-MM-DD (0h00)
  -e, --enddate ENDDATE                  The End Date - format YYYY-MM-DD (0h00)
  -a, --accuracy ACCURACY                Maximum Accuracy (in meters), lower is better
  -c, --chronological                    Sort items in chronological order
  -v, --variable VARIABLE                Variable name for js export
      --separator SEPARATOR              Separator to be used for CSV formats, defaults to comma
  -p, --polygon [lat,lon [lat,lon ...]]  List of points (lat, lon) that create a polygon.
                                         If two points are given a rectangle is created.

Special requirements for some options

-i, --iterative

The iterative parsing mode is achieved using the ijson.

To be able to use this option you will have to install it with

pip install ijson

-p, --polygon

Using this option you can specify a list of coordinates to define a polygon, and only locations that are in this polygon will be added to the output file.

E.g -p 43.665,10.334 43.815,10.492 to only include locations in the rectangle defined by the two corner points.

If you have negative latitudes you will need to but the coordinate in quotes with an extra space before the minus sign, so that argparse can detect and read the arguments correctly.

--polygon 20,-70 " -20,-50"

The polygon filtering is achieved using Shapely.

To be able to use this option you will have to install it with

pip install Shapely

On Windows this command will most likely fail. Instead you can download a wheel that matches your OS and Python Version from https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely

You can then install Shapely using this command:

python -m pip install Shapely-X-cpX-cpXm-winX.whl

Available formats

kml (default)

KML file with placemarks for each location in your Location History. Each placemark will have a location, a timestamp, and accuracy/speed/altitude as available. Data produced is valid KML 2.2.

csv

Comma-separated text file with a timestamp field and a location field, suitable for upload to Fusion Tables.

csvfull

Comma-separated text file with all location information, excluding activities

csvfullest

Comma-separated text file with all location information, including activities

json

Smaller JSON file with only the timestamp and the location.

js

JavaScript file which sets a variable in global namespace (default: window.locationJsonData) to the full data object for easy access in local scripts. Just include the js file before your actual script. Only timestamp and location are included.

jsonfull, jsfull

These types essentially make a full copy of the entries in the original JSON File in json or js format. With the option of filtering start and end date this can be used to create a smaller file in iterative mode, that can then be handled without iterative mode (necessary for gpxtracks and the chronological option).

gpx

GPS Exchange Format including location, timestamp, and accuracy/speed/altitude as available. Data produced is valid GPX 1.1. Points are stored as individual, unrelated waypoints (like the other formats, except for gpxtracks).

gpxtracks

GPS Exchange Format including location, timestamp, and accuracy/speed/altitude as available. Data produced is valid GPX 1.1. Points are grouped together into tracks by time and location (specifically, two chronological points split a track if they differ by over 10 minutes or approximately 40 kilometers).

More Repositories

1

mirror-api

Trying to reproduce the mirror-api behaviour using Google Cloud Endpoints to enable non-glass-explorers to get an idea of what will be possible.
Python
283
star
2

gplus-experiments

Various tools, scripts and apps created for the Google+ Platform.
PHP
56
star
3

chromecast_experiments

Various samples for Chromecast applications (mostly Chrome Sender/Receiver combinations)
JavaScript
48
star
4

scary-cube

Rubik's Cube as web-component based on lit-element
JavaScript
18
star
5

journey-to-the-moon

JavaScript
16
star
6

google-signin-samples

Some samples showing how to use the `google-signin` Polymer element in your own custom elements.
HTML
14
star
7

scary-gallery

Element to layout images making best use of available space.
HTML
13
star
8

cloud-vision-api-playground

Playing around with the new Google Cloud Vision API
HTML
13
star
9

discovery-api-elements

Automatically generated Polymer elements to access Google Apis
HTML
12
star
10

dart_endpoints

Implementation of Google Cloud Endpoints in Dart.
Dart
11
star
11

poke-icon

Gotta catch 'em all!
HTML
10
star
12

api-ai-interface

Polymer elements to interact with API.AI agents.
HTML
10
star
13

scary-giiker-cube

Time your Rubik's cubes solves with the GiiKER cube
JavaScript
9
star
14

chrome.sphero

Sphero API for Chrome Packaged Apps
JavaScript
9
star
15

scary-cast-receiver

Helper element to develop Custom Google Cast Receivers
HTML
8
star
16

MarvelMatch

Dart Flight School hackathon project
Dart
8
star
17

gdg-endpoint-demo

Introduction to Google Cloud Endpoints
Python
8
star
18

polymer-starter-kit-firebase-hosting

Using Cloud Functions for Firebase for differential serving of different Polymer builds.
HTML
7
star
19

location-history-trail

Fun visualization of your location history data
JavaScript
6
star
20

comment-tracker

Keep track of comments on Google+ posts, YouTube Videos, Google+ searches and Twitter searches.
JavaScript
6
star
21

dart_people_mosaic

Create a Photo mosaic based on your profile image and the people you follow.
Dart
5
star
22

scary-cast-sender

Helper element to develop Google Cast Chrome senders
HTML
5
star
23

scary-cookie-consent

A Polymer element to make it easier for you to display those annoying cookie messages
HTML
5
star
24

google-drive-viewer

(Incomplete) proof of concept to show that the Drive API (https://developers.google.com/drive/) is powerful enough to build your own custom UI instead of using https://drive.google.com/
HTML
5
star
25

picasa-album

Polymer web component to easily embed a Picasa/Google+ photo album.
HTML
5
star
26

polymer-discovery

Sample using polymer to display discovery API documents
4
star
27

all-my-plus-statistics

Various reports based on either public Google+ posts or takeout data
PHP
4
star
28

appengine-endpoints-tictactoe-client-dart

A simple client for a Tic Tac Toe game using Google Cloud Endpoints and Dart.
Dart
4
star
29

gae-gcs-push2deploy-secrets

Sample to show how to keep your secrets secret while having your Google App Engine projects open-sourced and connected to GitHub for Push-to-deploy.
Python
4
star
30

people-api-demo

Playing around with the new Google People API
HTML
3
star
31

DartPlusDemo

Simple library to access the Google+ REST API in Dart
Dart
3
star
32

aoc2019

My attempts at solving the daily coding challenges of Advent of Code 2019
Python
3
star
33

aoc2020

My attempts at solving the daily coding challenges of Advent of Code 2020
Python
3
star
34

chrome.ev3

LEGO EV3 API for Chrome Packaged Apps
JavaScript
2
star
35

scary-cookie

Polymer element to read and write cookies
JavaScript
2
star
36

mirror-api-examples

Some sample applications that make use of the Mirror API
Python
2
star
37

appengine-vm-endpoints-tictactoe-dart

A simple Tic Tac Toe game using Google Cloud Endpoints, App Engine, Managed VMs and Dart.
Dart
2
star
38

generator-polymer-init-custom-app

Based on the starter-kit template with more customization options
HTML
2
star
39

chrome-storage

Get/store values via the Chrome Storage API
HTML
1
star
40

payarcade

DevFest Vienna 2013 Hackathon Demo
JavaScript
1
star
41

scary-mdx-table

WIP, Details TBA
HTML
1
star
42

lao-helper

Basic Lao language information
HTML
1
star
43

scary-mdx-data

A helper element to transfer a raw mdx query result into a suitable format for the other scary-mdx elements
HTML
1
star