top of page

Project Date: 

October 7, 2019

Who doesn't hate sitting in traffic?


Personally, I loathe it.  My commute is 53 miles one way and as much as I enjoy a good podcast or audiobook, traffic still gets on my nerves.  After driving the same commute for a couple years, I had begun to notice patterns in how busy the roads are at various times of the day.  So I decided to quantify and analyze these patterns.


Google Maps API and Python


Knowing nearly nothing about Google Maps API, I enabled a Google Cloud Platform account (super easy) and generated a "distance matrix" API key.  There are some nice help docs available on the GCP site that explain how these APIs work and how to query them in different languages.

Using PyCharm CE on Mac OS (a nice Python IDE), I was able to get the Google Maps API connected and start to query the "distance matrix".  This API allows you to retrieve a matrix of origins and destinations in human-readable address format (123 Main St, Any City, MD) and it will return the distance between the two and, most importantly, the current travel time in seconds accounting for current traffic.


Google Cloud VM


I modified the code a bit to run every 30s throughout the day and also write the travel time in both directions to a csv file.  Then I setup an extremely lightweight Google Cloud VM instance to run my query 24/7/365.


After several weeks of running, the data you see in the plots are from Google Sheets after I imported the csv files and manipulated the data a little.


Conclusions


Get a job closer to home.


Seriously, leave before 6:30AM and I'll rarely have trouble getting to work.  Coming home I should leave after 5:30PM and never go to work on Thursdays or Fridays.

CONTACT ME

Darren Brown

PROFESSIONAL ENGINEER

MD License Number 50081

Phone:

909-353-7531

 

Email:

dbrown.gm@gmail.com 

  • Black LinkedIn Icon

Thanks for submitting!

© 2020 By Darren Brown

bottom of page