Skip to content

Latest commit

 

History

History
18 lines (14 loc) · 1.38 KB

README.md

File metadata and controls

18 lines (14 loc) · 1.38 KB

Track your commute times

Setup

  • Get your Google Maps API key. Copy config.json.sample to, say, config.json and put your key in it.
  • Copy inputs.json.sample to, say, inputs.json and put your start and destination addresses there. You can have multiple pairs here. The script will compute both 'to' and 'from' commute times between the two points.
  • Run 'python traffic_snapshot.py input.json config.json'. This will create a directory 'data' and record your commute times in csv files there. '_out' files represent going from start to destination and '_back' files represent the reverse.
  • Create a cron job to run the script every few minutes. Something like */15 * * * * /usr/bin/python /home/ec2-user/peak_hours/traffic_snapshot.py /home/ec2-user/peak_hours/input.json /home/ec2-user/peak_hours/config.json
  • You can play around with the data in csv files in Excel.

Uploading charts to plotly

  • Sign up on https://plot.ly and get your API key
  • Follow "Hosting on Plotly" instructions here https://plot.ly/python/getting-started/ (install plotly and configure the api key)
  • Run 'python plot.py input.json'. It will upload the csv files generated by traffic_snapshot.py to plotly. You can see the charts in 'My Charts' section on http://plot.ly
  • You can create a cron job now. Something like * */1 * * * /usr/bin/python /home/ec2-user/peak_hours/plot.py /home/ec2-user/peak_hours/input.json