02

Lines

Where does the tube *actually* go? Hand-coded

#30DayMapChallenge prompt: A map challenge classic. Map with lines.

Why this map

I live near Finsbury Park and I've wondered for a while now how can the Picadilli line section between Finsbury Park and Manor house take so long? I want to understand where does the tunnel go... is it going around the park, and that's why it takes longer than it feels like it should..? The answer is no, the line crosses through the park. I guess it must just be the speed at which it travels. We'll have to take a look at that another day.

Data sources

London Underground tunnels ↗

From
OpenStreetMap contributors, downloaded via the Overpass API (overpass-turbo)
What
764 stretches of track in tunnel on the 11 London Underground lines (OpenStreetMap tags railway=subway + tunnel=yes), covering both the deep tube and the shallower cut-and-cover lines. Drawn by volunteers, not an official TfL plan.
Time
Snapshot of OpenStreetMap at 2 Nov 2026, 18:57 UTC; the tunnels opened between 1863 and 2022
Resolution
Approximate. Tunnels can't be seen from above, so mappers worked from station positions, old maps and local knowledge. Of 368 km of track, mappers themselves flag about 76 km as interpolated, guessed or traced from old maps (including 34 of the Jubilee line's 39 km, and about 15 km of the Northern line marked “route is a guess”). Another 278 km doesn't record a source at all.
Licence
ODbL, © OpenStreetMap contributors

How it was made

Pythonfoliumgeopandas
See the code (map.py)
"""
Day 2 · Lines
The prompt: A map challenge classic. Map with lines.

What I'm mapping: (write one sentence here once you've decided)

Run it from the project folder:
    python days/02-lines/map.py
It saves map.html next to this file. Then see it on the site with:
    python build.py --serve
"""

from pathlib import Path

import folium
import geopandas as gpd

from mapkit import palette as P
from mapkit.folium_style import OSM_DATA_CREDIT, add_basemap, add_credit, style_map

HERE = Path(__file__).parent      # this day's folder
DATA = HERE / "data"              # put the data files you download in here

m = folium.Map(location=[51.517529617507, -0.11694326581724193], zoom_start=12, tiles=None)
add_basemap(m, "light")           # background map: also "light-nolabels", "dark", "osm", "mapbox"
style_map(m)                      # the site's font + ink-outlined buttons
add_credit(m, OSM_DATA_CREDIT)    # the tunnel lines are OpenStreetMap data (ODbL), so credit them on the map
gpd = gpd.read_file(DATA / "tube.geojson")
#print(gpd.describe())  # gives a summary of the numeric columns, does not say much about the text columns.
#print(len(gpd)) #how many gates there are.
#print(gpd.columns) #the names of all 157 columns.
#print(gpd.head()) #the first 5 rows of the data, to see what it looks like.
print(gpd["line"].unique())

for _, row in gpd.iterrows():
    folium.PolyLine(
        locations=[[coord[1], coord[0]] for coord in row["geometry"].coords],
        color=P.TUBE_LINES[row["line"].split(";")[0]],
        weight=3,
        tooltip=row["name"],  # replace with a column that makes sense for your data
        popup=f"Line Name: {row['name']}"  # replace with a column that makes sense for your data
    ).add_to(m)


m.save(HERE / "map.html")
print("Saved", HERE / "map.html")

Doing the challenge too? Use this template for your own →