Introduction to Research Software Engineering with Python: Planning Tube Routes Services
Disclaimer
The information provided by this service uses a combination of data from 2017, and more recent sources obtained through the TFL API. It does not necessarily reflect the current state of the London Underground or wider Transport for London network. Tube enthusiasts be warned that some stations (and possibly line-links) might be missing!
Overview
Transport for London (TFL) operates a number of public transport services for getting the people of London around the city as efficiently and quickly as possible. The routes and infrastructure that comprise this service are collectively referred to here as the "TFL network". This web service is designed to imitate an service that allows the public to retrieve information about the layout of the TFL network, as well as access a number of (made-up) proposals to enhance the transport network with the addition of routes.
Click to show the TFL network map.
For the purposes of this service, the TFL network is divided up into 21 lines, with a total of 446 stations - note that the term "stations" may refer to any of a tube station, tram stop, or overground rail station.
Each line is given a unique index so that it can be identified by the backend API of the web service - these indexes run from 0 through to 20 (inclusive).
The stations are also each given a unique index between 0 and 445 (inclusive), again used to identify and interact with the information the web service stores in the backend.
You can read more about the services that can be queried below.
General Information
By querying the index/query service (at the https://rse-with-python.arc.ucl.ac.uk/tube-planning/index/query address), you can retrieve a json file containing:
- The number of stations in the network.
- The number of lines the London tube network is divided up into.
- The correspondence between the names of the underground lines and their indexes (see the table on the line networks page for more information).
- The names of the proposals that can be fetched from the
proposals/routesservice.
This query does not take any keywords, and returns a json file in the following format:
"n_stations": 446,
"n_lines": 21,
"lines": {
0 : "line_0_name",
1 : "line_1_name",
...
},
"proposal names": [
"route name 1",
"route name 2",
...
]
Line Networks
The layout of the TFL network is publicly available for to viewing and download, and this information is offered by the Line Networks service. This service provides information about which connections (between stations) belong to which line in the network, and how long it takes to make each connection.
Station Information
The stations in the network each have a name, however the primary piece of information attached to each station is its unique station index. The information provided by the other services identifies stations by this index. As such, the purpose of the Station Information service is to be able to translate between the station indices and their names. The service also provides some additional information about the stations, including whether they are National Rail terminals.
Proposed Lines
The TFL network is vast, and has undergone a number of expansions and re-organisations in recent years; the opening of the Elizabeth line and the reorganising of the Overground into smaller, contiguous lines to name a few. As such, it is natural that plans to expand the network are under consideration, or at least in the pipeline, at all times. The Proposed Lines service provides access to some of these potential expansion options, as well as some supporting information on how proposals are assessed in terms of their cost to construct and the benefit to travel they provide.