Google Maps Travel Tool
Today, I finally got around to doing something that I had been meaning to do for quite a while!
That thing is creating a GitHub repo for a little software tool I made a few months ago, which I’ve now dubbed as my “Google Maps Travel Tool“.
If you want to cut to the chase, here’s the link to the repo:
What is the Google Maps Travel Tool?
To give an example, you can ask the script to take as inputs:
Origin: Annerley, Queensland, Australia
Destination: Brisbane CBD, Queensland, Australia
Mode: driving (i.e. car)
And it can tell you that the distance driving is 6.095 km and departing at 7am on a Tuesday morning, it will take 9.68 minutes at an average speed of 37.76 km/hr.
This is pretty cool, but what makes it useful is that it can take a massive list of inputs in a CSV file and automatically do these calculations. The inputs in the CSV file include the origins and destinations, as well as several other factors such as travel mode (e.g. car, transit, cycle or walk), routes to avoid and time of travel, etc. and it outputs the travel time (minutes), distance (km) and average travel speed (km/hr) in CSV format.
See the outputs_example.csv file for an example output, based on travel to the Brisbane CBD from all around the city!
What can it be used for?
I made the Google Maps Travel Tool to provide a tool to undertake analysis of transport patterns around cities. By setting up a matrix in column format, the tool lets you quickly skim travel time, distance and speed data. This makes it useful for transport modelling and planning tasks.
Another use I found for it (which may be subject to another post in future) is to find an accessible suburb to live in! As you can see in the outputs_example.csv file, I’ve analysed the travel time for each suburb in Brisbane to access the CBD (which is where I work). So if I want to live within 30 minutes via public transport, I can see which suburbs would meet that criteria.
How does it work?
Google Maps Travel Tool is scripted in the python programming language. Within it, the script uses the CSV module to work with data in the CSV (Comma-Separated Value) format. As you may have guessed, the tool uses Google Maps to crunch the travel distances and times. More specifically, it uses the Google Maps Distance Matrix API and its XML data format version of the API (Application Programming Interface).
To use the tool for yourself, simply sign up for a Google Maps API authentication key (API Key) and include this at the start of the python script where specified, along with your input and output CSV file names.
This post was an overview of the Google Maps Travel Tool project as available on GitHub. I hope it’s helpful. No doubt there’s some improvements that can be made to it, so please get it touch via here, GitHub or Twitter if you have any questions or feedback.