Part 1 — the plain-English version

Predicting when the barriers come down

In short: we watch the railway's own signalling to see trains approaching Mount Pleasant Road crossing, and we've learned from real data exactly how long each train takes to arrive — so we can tell you, to within about a minute, when the barriers will next close.

A level crossing is annoying mostly because it's unpredictable. You can see a barrier is up now, but that tells you nothing about whether you've got four clear minutes or you're about to wait for a train. The goal of this project is to turn "maybe" into "the barriers will come down at 18:53, for about 90 seconds."

How can a website possibly know that?

Every train on the national network is tracked by the signalling system. As a train moves, it steps from one short section of track to the next — think of it like beads sliding along a string. Each section has a name, and the signalling broadcasts "train 1W35 just moved into section 0352" in real time. We listen to that feed.

The crossing is protected by four signals. When the signaller sets a route for a train over the crossing, that's the moment the barriers drop. So if we can see a train a few sections away and know how fast it's moving, we can count down to that moment.

The hard part: not all trains, or track, are equal

Early on, our guesses were often wrong by several minutes. The reason turned out to be simple, and it's the heart of how this works now:

So instead of guessing, we measured. We watched thousands of real train movements and learned, for every section of track, how long a train actually takes through it — and separately for trains that stop at the station versus those that don't. The prediction is just adding those measured times together along the train's path.

Two ways of knowing, cross-checked

We keep ourselves honest

Every prediction is checked against what actually happened — did that train really cross, and how close was our timing? Those scores are public on the scoring page. And the system re-measures itself every night from the latest data, so as track, timetables and traffic change, the predictions stay calibrated.

What we genuinely can't know

Some things are simply invisible to us, and it's only fair to be upfront about them. A signaller can hold the barriers down by hand — through several trains in a row, or to manage road and rail traffic together. When that happens the crossing staying shut isn't a mistake on our part; we just can't see the signaller's intent. Trains can also divert or be cancelled after we've predicted them, so they never arrive.

One subtlety about what "barriers down" means. The closure happens through a sequence: the barriers lower, the crossing is confirmed clear, the signaller's route over the crossing is set, and that route "proves" — which is the step we see in the data. We used to worry this lagged the real barriers-down by an unknown amount. But standing at the crossing and timing it, the barrier sequence starts essentially the moment the route is set — so the signal we track is a faithful, near-immediate marker of the barriers coming down, not a delayed one. (If you can help us measure the last few seconds precisely, see below.)

That same fact shapes the forecast. The signaller sets the route ahead of the train — so the barriers start coming down before the train reaches the crossing, and by a different amount on each line (much further ahead on the faster Down line than the Up). We measure that per-direction lead from the data and subtract it, so the time we give you is when the barriers drop, not when the train arrives.


Part 2 — the technical version

Under the hood

The track layout — and why it's tricky

First, the ground truth, because none of the rest makes sense without it. Mount Pleasant Road crossing sits just south of St Denys station, on the busy approaches to Southampton. The signalling divides the railway into short sections called track circuits (in the data, "berths" — each has a 4-digit id like 0703); a train lights up one section at a time as it moves, and that's the signal we track.

A few features of this specific location are what made naïve prediction fail, and they shape the whole model:

The last two points are the crux: the signalling topology tells us what's physically possible, not what actually happens. If we trusted it blindly we'd forecast closures from track that never feeds the crossing. So we learn the operational direction from observed movements (see "spurious-berth pruning" below), rather than from the wiring diagram alone.

Data sources

Detecting a closure

Mount Pleasant is protected by signals 707 / 709 (down) and 708 / 710 (up). The barriers-down proxy is a route set over the crossing from one of these signals — read from specific S-class route bits. A train physically clearing the crossing (a step on a known exit edge, e.g. 0709→0713) marks barriers-up and confirms which train actually crossed.

Tier 1 — live forecast (no timetable)

A reverse breadth-first search over the signalling stepping table, starting from the four crossing berths, labels every upstream berth with its path to the crossing. The key refinements:

a train stepping toward the crossing — ETA = sum of measured edge times (− time already elapsed) 0352 ──38s──▶ 0701 ──32s──▶ 0705 ──24s──▶ 0709 ★ crossing (down approach) (St Denys plat.) (barriers down) +stop dwell if booked to stop here

Tier 2 — timetabled forecast

CIF schedules are STP-resolved for the day, projected to their booked St Denys time, shifted by each train's live TRUST delay, with cancelled trains dropped. Back-to-back trains merge into a single closure window.

Scoring

When a train crosses, its prediction is credited as a hit only if it crosses within a grace window of the predicted time — matched to the right prediction for that headcode (headcodes recur through the day, so naïve matching corrupts the metric). We report MAE (mean absolute timing error on hits), precision (of predictions, how many happened) and recall (of closures, how many we called). A train held on approach and re-predicted from a closer berth has its earlier prediction marked superseded, not missed.

MetricWhat it means
MAEhow far off our timing is, on average, for trains that crossed
Precisionof the predictions we made, how many resulted in a real closure
Recallof the closures that happened, how many we predicted

Known limitations

Several things bound the achievable accuracy, and they're worth stating plainly:

This is why the closure record — measured directly from the signalling — is more dependable than any single prediction, and why we publish honest, self-scored numbers rather than one headline figure.

Can you help us see the barriers? 📷

The one thing we can't get from the data feed is the real moment the barriers go down — and the lead between that and what we detect (the "route proves" step). To measure it we need ground truth from the crossing itself:

Either would directly improve the times everyone sees. If you can help, please get in touch: [email protected].

Continuous recalibration

Each night the system re-measures per-edge transit times, platform dwells and spurious berths from a rolling window of recently captured movement data, writes them to disk, and the live model hot-reloads them — no restart, no human in the loop. Predictions improve as the dataset grows and adapt as the railway changes. Captured data is archived off-box and pruned locally so the calibration loop never fills the disk.

Soton Crossings currently covers Mount Pleasant Road at St Denys; once the technique is proven here, Adelaide Road (a simpler layout) will follow. Built on open Network Rail data feeds (NROD). Live view: sotoncrossings.co.uk · Scoring: /stats