Graphing the commute time to Uni from different possible wellington flats

2018-03-23 | Python , Html , Web ,

Why?

Basically, during my flat hunt one of the most important criteria for choosing a place was the distance and commute time to uni. Ideally somewhere close enough that I could walk to uni is the best option, but I dont mind taking a bus. Living at home, my commute was a 45 minute train ride plus a 15 minute drive to the train station, and a 20 minute walk from the station.

How?

How do I get a list of addresses for flats that were on the market? Trademe! Trademe offer an API to do this very easily, but from my understanding you need to apply for a license to be able to use the api on the main website. Now, I didn't want to do that just to run a one-time script so I did the next best thing: web scraping. Using Beautiful soup I was able to pull the street address off of each listing on a filtered trademe search.

Next, I had to use the google maps api to give me the travel time to the uni from each flat. Because google maps can only take so many queries at once I had to split each call up into chunks of 5 or 10 addresses. I did this for both transit(Bus/Cablecar/Train) and walking. For us, the most relevant chart was walking as we really want a place that is within walking distance.

Then, using that, I graphed the results with Matplotlib:

The graphs

Weirdly, the first graph seems to show a big chunk being under 25 minutes and then a big chunk after that. I theorise that this could be because of the line between 'inner city' flats and 'outer city flats' - ie outside the CBD area. Alot of student accommodation in Karori is over 25 minutes away - I imagine this is likely due to all the flats that are 25 minutes away are all rented already and people like the location.

update 15th July - Well, alot of the bus routes have changed as of today, but I theorise the results are still mostly relevant.

Where to go from here?

I could try making a graph of price versus travel time and try look for correlations. Also, I could take different readings throughout the year and try see if the available flats get further away as time goes on and students move into the close ones.

Wheres the source code?

When I was installing linux on my surface tab apparently bitlocker was enabled (???) and triggered after I changed the partition size of windows causing the tablet to lock down completely. After multiple calls with microsoft support it turns out they dont store the keys anywhere to get my computer unlocked. In all my infinite wisdom I forgot to check the source code into source control so now ive lost it... hopefully theres a backup somewhere on my network.