Play it again, Sam!
After the ‘tremendous’ feedback, I have got for my previous blog posts about the public transport in Dresden, I have decided to jump on the next Niederflurwagen (one heck of a word for Scrabble) and look at some more interesting bits and pieces. This time, connectivity and changeovers shall be the center of our analysis.
This needs a closer looks at bus and tram routes. These are the main factor of connectivity between two stops. In our case, we will assume that each stop is connected to another stop if they share at least one route serving both stops. Of course, stops can be connected via several lines. This is quite common for stops in the city center because there are a lot of routes going through this much frequented area. Let’s have a look at an example. The following map shows the central stop on the university campus in Dresden. It is marked with an enlarged point. The blue points are stops which are reachable directly with a line from the university stop. This includes the infamous bus route 61 which is known for its spacious rides (representative image). The gray points are stops which are only reachable with changeovers to other routes.
The HTML is rarely pure and never simple.
How do we get route data for the public transport in Dresden? You have probably guessed it. There is no easy way. Routes are not stored in the csv from the VVO repo and the web API does not provide any useful endpoints either. So, we are forced to crawl and parse HTML. And there was much rejoicing. Yaaay! The entry point for all this is the website for route time tables. After some brain-hammering scraping and cross referencing with the web API, we finally get a connectivity graph for Dresden.
Expert note: The names do not match over all sources. To overcome this problem, I used the Jaccard coefficient on the bags of bi-grams of stop names. But this is not what we want right now. Our focus should be the number of changeovers you will need to get from one stop to another. Therefore, I connected all points of one route with each other. This means all stops on a route have distance 1 because you can get there with 1 line. Changeovers to other lines increase the distance by 1. The length of the shortest path from one stop to another gives the number of changes. Let’s take the university stop (enlarged point) and color code all reachable stops. I have chosen a traffic light color map. Green means directly reachable with a line. Yellow means one change and red two changes. Grey stops need more than two changeovers. One point which our connectivity analysis shows is that the northwest is harder to reach from the university compared to other areas in Dresden. The segmentation of cities into such ‘route segments’ is a general observation. Parts of the city can be cut off by unfortunate route placement. This does not seem to be a big problem in Dresden, but this could be different in other cities. To give you a positive example, we can expand our analysis to another stop in Dresden, like Postplatz. This is a central hub with a good connectivity, shown by the fact that you can reach a lot of stops from here with no (green) or just one (yellow) changeover. And again, you can clearly see the star schematic of Dresden’s public transport network.
That’s all folks
We have shown two things here.
- Data collecting is still laborious,
- Public transport routes can segment a city into areas with different quality of reachability.
There are a lot of points which I did not examine, e.g. our analysis does not cover any time-relevant aspects. Changes do not only depend on the course of routes, but also on their time tables. Sometimes, especially at night, the stops where you have to change differ remarkably. Some stops are not serviced at night and others are serviced by different routes. This is not modeled in our connectivity graph.
Oh, this is my stop, so I am getting off here. I hope you enjoyed the ride as much as I did. Bye and therefore back to David Bowie, Master of changes.