donybenedict / google_traffic

Gathering and Analyzing Traffic Data from Google Map's API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

google_traffic

Google Maps tool for obtaining estimated trip times.

Description

traffic_times.py is a Python 2 script that retrieves 3 travel duration estimates working off the assuption that you depart at the current time.

Google API Key Requirements

For this project, you'll need a Google API Key. You can do so here: https://developers.google.com/maps/documentation/javascript/get-api-key#key

  1. Create a Google Developer Project. Link
  2. Enable Google Maps Directions API.
  3. Click 'Use Google APIs' (a blue box).
  4. Stay on Overview tab.
  5. Click more in Google Maps API section.
  6. Click 'Google Maps Directions API'.
  7. Click 'Enable API' button.
  8. Create Server API Key.
  9. Click Credentials tab.
  10. Click New credentials.
  11. Click API key.
  12. Click Server key.
  13. Name your key.
  14. Click Create.
  15. Copy your key.
  16. Set googleMaps.self.key to your API key.

Usage

+traffic_times.py [-h] [-tm {best_guess,pessimistic,optimistic,all}] [-d {to_work,from_work}] + +### Arguments + +``` +-h, --help shows this help message and exit +-tm {best_guess,pessimistic,optimistic,all}, --traffic-model {best_guess,pessimistic,optimistic,all}

  •                    traffic model to use
    

+-d {to_work,from_work}, --direction {to_work,from_work}

  •                    direction of travel
    

+``` +

Recommended Setup

I have my crontab setup to run the following:

Run to_work during morning commute times: */10 11-15 * * 1-5 /usr/bin/python traffic_times.py -tm all -d to_work

Run from_work during evening commute times: */10 19-23 * * 1-5 /usr/bin/python traffic_times.py -tm all -d from_work

I run the r script from time to time to update graphs (Rscript traffic_plots.R)

About

Gathering and Analyzing Traffic Data from Google Map's API

License:MIT License


Languages

Language:Python 63.2%Language:R 36.8%