GithubHelp home page GithubHelp logo

ralic / spark-location-history Goto Github PK

View Code? Open in Web Editor NEW

This project forked from clamm/spark-location-history

0.0 3.0 0.0 2.41 MB

Application that visualizes your google location history in form of a heatmap using Spark to aggregate the data.

License: Apache License 2.0

Python 38.14% HTML 8.26% JavaScript 41.19% CSS 12.42%

spark-location-history's Introduction

Visualize Your Location History!

Google is storing your location history if you have an Android phone and enabled location reporting (see https://support.google.com/gmm/answer/3118687?hl=en).

This is an application that visualizes your location history in form of a heatmap using Spark to aggregate the (potentially huge amount of) data, e.g.:

Example of Location History Visualization

Get started

Here is the overview of the data flow:

Data flow

In order to get started do the following:

1) Download your location history data

Download your location history data at https://www.google.com/settings/takeout You can deselect everything but the Location History. Click next and wait until your location history data is ready. When the data is downloaded, unzip it and put it in the data/input/ directory in your checkout.

2) Install InfluxDB, Spark and Python packages

[Mac] Install InfluxDB:

$ brew install influxdb

[Mac] Install Spark:

$ brew install apache-spark

Install Python (version 2.7) packages:

$ pip install -r requirements.txt

Start InfluxDB:

$ influxdb -config=/usr/local/etc/influxdb.conf

3) Import your data

Load your data into the database by running the following script:

$ cd src/import-data
$ python insert-data-into-influxdb.py

You can check the loaded data by opening a web browser at http://localhost:8083/. Login with the standard credentials (see getting started guide), click on explore data for location_history and enter the following query:

select * from locations limit 100

4) Process data via Spark

Spark processing flow

We use Spark as aggregator to efficiently visualize the (possibly TB large set of) collected location data. More specifically we

  1. calculate a geohash value for each latitude/longitude pair for a given precision
  2. count how many points fall into that geohash area

When visualizing the areas on the heatmap we need to reconvert the area geohash to latitude/longitude values as per requirement of heatmap.js. Spark writes this aggregated data to a file in data/output/spark_out_data.json together with two more files containing meta data.

Run the Spark processor to count how many points fall into which areas and write the output to a file

$ cd src/process-data
$ spark-submit process-data.py

5) View the heatmap

In order to visualize your location history, i.e. how often you have been at a certain location (during an interval of time), we construct a heatmap overlay over a google map. The input data for the heatmap are files generated by Spark and located in data/output/.

Start a webserver (e.g. python SimpleHTTPServer) from the project directory root:

$ python -m SimpleHTTPServer 1338

Now head over to your favourite browser and visit: http://localhost:1338/src/visualize-data/

Notes

The following dependencies are shipped with this repo:

heatmap.js expects the following data format for its visualization:

[
    {
        'lat': 24.6408,
        'lng':46.7728,
        'count': 3
    },
    {
        'lat': 24.6408,
        'lng':46.7728,
        'count': 3
    },
    ...
]

spark-location-history's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.