You’ve reached the end of the line.

search

Transit can now detect where your bus has been detoured

Even if the detour is unannounced. Starting in Montreal: the Bermuda Triangle of wayward buses šŸš§šŸ‘‹šŸ‘·ā€ā™‚ļø

February 27, 2023

En franƧais svp

Sometimes your local bus takes the long and winding route.

Bus detours happen for all sorts of reasons. A street gets pedestrianized, or repurposed for bike paths. The tin whistle of a protest gives the streets back to the people. Construction happens. Maybe the city let its resident acrobats throw a street festival, and now the traffic lights swarm with backflipping clowns.

No one understands the game theory of bus detours better than folks in Montreal. The city’s transit agency, the STM, has to wallop its way through a whack-a-mole of road closures: more than one in six bus routes are detoured — a higher number than any other Transit-supported city.

That’s why, together with the STM, we’ve built software that can now detect detours automatically šŸ¦¾šŸ¤– and show them in Transit for easy viewing — often under an hour after the detour first starts!


We’ve wanted to build a detour detector for years. We often hear complaints from riders about stops being moved: paper notices at the stop aren’t helpful if your bus is already blazing away on its new detoured route. And while many agencies publish their detour info ahead of time, they’re usually posted in big Babylonian walls of text:

So why hadn’t we built a detour detector until now? Generally, we know the GPS coordinates of most buses. Making a rough sketch of a detoured route? Tricky, but not impossible.

However, without knowing where drivers were actually stopping to pick up passengers along a detoured route, we couldn’t reliably tell our riders where to go while a detour was in effect.

Recently, though, we started working with experts at the STM. With their clarification of gnarly edge cases like express route detours and rush hour detours, we’ve developed a better understanding of how detours in Montreal work, and how to reliably map them.

Transit’s detour detector shows the revised path of your bus route and your closest temporary stop.

Finally, we can validate detours in real-time. We now send riders to relocated stops — without having to map the new routes (or input stops) manually.

Our detour detector monitors bus lines for deviant behaviour 😈 — if a bus is repeatedly straying from its normal route, we integrate its new path, and the new stops, into Transit.

It’s something no other app does: not Google. Not Apple. Nobody.


PART 1: DETECTING ROUTE SHAPES

The idea behind automatic detour detection is simple enough: if we see that the real-time position of a bus does not match its regular route shape, we flag that trip.

If three consecutive buses deviate from their expected route shape, then we know that the bus driver isn’t getting lost, but that there’s a probable detour.

We take those wandering buses, match their fuzzy GPS positions to the actual street grid, and build a route shape for the detoured segment.


PART 2: DETECTING TEMPORARY STOPS

At this point, we’ll show the new detoured route shape in the app.

But where, specifically, will the bus be making its stops along the detoured segment? This is a bit trickier.

How do we predict where those new bus stops are?

While most buses report their real-time position via GPS, the quality of bus position data can vary. Some GPS transponders upload bus positions every few seconds, some take a minute or longer.

We can fill in some of these gaps with our own real-time position data: Transit riders crowdsourcing their trips with GO, and this data can supplement what we get from GPS transponders.

When riders use our ā€œGOā€ crowdsourcing feature, they share their bus’s second-by-second location.

But even with the remaining gaps in the real-time data, we can sniff out a recently-stopped bus from one that hasn’t stopped in a while. By looking at bus position data, we can derive the acceleration of a bus between any two points.

With enough data points, we can…

  1. Pinpoint where the buses are reducing and increasing their acceleration (and flag these as ā€œpotential stopsā€)
  2. Compare acceleration patterns at ā€œpotential stopsā€ to ones at existing stops
  3. Remove false positive ā€œpotential stopsā€ where the bus does not pick up passengers

…to interpolate where the bus stops actually are.

Yes: our model can detect the very subtle differences between a bus that stops at a traffic light and picks up passengers vs. a bus that stops at one and does not 🤯

Thanks, Galileo! (And machine learning…)

The drawback of this approach is that it’s like drawing someone’s portrait by looking at their shadow: you need a lot of shadows at different angles to construct a portrait, and even then your portrait won’t be perfect!

Our hope? If we can get you within a few metres of a detoured stop, you’ll be close enough that you won’t miss your bus. šŸ¤ž


PART 3: PUBLISHING DETOURS

How do we translate all this data into beautiful maps and trip plans that our riders can use? And how do we then share it all back with transit agencies, like our trusty confrĆØres at the STM?

Transit agencies like the STM use a system called GTFS to broadcast useful transit information, like:

Stop locations, departure times, and route shapes are (for the most part) static data which don’t require much work to maintain. Most agencies only update their GTFS a few times a year.

Detour info, however, requires a hands-on approach.

To show accurate detours, a transit agency would have to be notified of every road closure in advance (they’re not) and they’d need to constantly monitor / edit / republish their GTFS. Ain’t nobody got time for that. Or budgets, for that. 😩

However, with some data wizardry, we can update GTFS with detours ourselves. We skip the minutes and hours that it would take to edit and compress a big bulky GTFS file: as soon as we detect a detour, we chop out the affected GTFS segment, commit our changes, sew it back into the pre-compressed GTFS, and make it visible to you. This is all automated, a big beautiful ballet of transit DNA that can miraculously repair itself.

Transit users will now see detours appear in the app like magic. Route shapes, stop locations, and trip plans will show up in (almost) real-time — and that’s important, because detours might only be around for a few hours or days.

Detours are continuously updated, making sure your trip stays on track. Hawk-eyed users might see the route shape and bus stop locations evolving, as we collect more data about a specific detour, minute-by-minute.

As a final measure, our team creates a data feed with these new detoured shapes and stop locations, and shares it with the agency. The STM, for example, is already using Transit’s real-time detour data to update the route maps on its website! šŸŽ‰


DETOUR DETECTION: NEXT STEPS

Thanks to the STM’s help, we can now reliably detect the pesky detours that afflict Montreal’s bus routes, and guide riders to relocated stops.

It’s a beta project with room for improvement, but we’re already impressed by the results: bus detours have never been so comprehensively and accurately catalogued! In the next couple of years, we expect paper detour notices to go the way of paper schedules at the bus stop — they’ll still exist, but you’ll also be able to get the info on your phone much faster.

We’ve already got our sights set on the next iteration of detours: our updated model will be able to handle recurring detours šŸ”„, make predictions for departure times at detoured stops šŸ”®, and give proper names to every temporary bus stop you encounter šŸš.

We’ve also put forward a proposal that standardizes this new way of organizing detour data feeds, making it easy for any transit agency to share real-time detours with their riders. That proposal is currently being considered by the overlords who oversee GTFS šŸ™

But whether or not your agency supplies detour information — our detour detector will ensure the app is always showing you where detours are, and where buses are actually running.


If you’re a transit agency and want to notify riders about detours on your network? The STM blazed the trail — but you can be up next! Let’s detect those detours. You know where to reach us šŸ‘‹šŸ˜Ž
PBS outro voice: this feature was built in partnership between the STM and Transit, and was made possible with support from the government of QuĆ©bec. And viewers like you. Merci! šŸ‘‹
Recent articles
Our mission:
make cars obsolete.
Get Transit