Public transit & GTFS
Timetables as data: GTFS feeds, service calendars, frequency, transit travel times and the realtime feeds that correct them.
A transit feed is a timetable stored as a database. Routes are labels, trips are journeys, and the times live in one enormous table that only makes sense once a calendar has said which dates each trip runs on. Every question here — how often, how far, how many people — is a join across four or five files, and the calendar is the one most often skipped.
What makes the subject hard is time. A GTFS time can read 25:10:00, a holiday can remove one timetable and add another, and the travel time between two places depends on the minute you leave, because missing a bus by a minute costs its whole headway. Almost every error in this topic is a number that looks reasonable: a frequency counted across both directions, a catchment drawn as a circle, a travel time taken from the best departure of the hour.
The concepts below cover the feed, its calendar, headways and accessibility; the how-to guides read, clip, map and route across a real feed; and the fixes are filed under the symptom — times past midnight, empty dates, straight-line routes and travel times that flatter the network.
🧭 Start with the concepts
The ideas the how-to guides below assume you already have.
- GTFS explained: the tables behind every transit feed gtfs explained
- GTFS service calendars explained: calendar, calendar_dates and the service day gtfs calendar_dates explained
- Transit frequency and headways explained transit headway frequency
- Transit accessibility explained: why travel time depends on the minute you leave transit accessibility travel time
- GTFS Realtime explained: trip updates, vehicle positions and alerts gtfs realtime explained
⚙️ Then do the task
Step-by-step walkthroughs with code you can copy and adapt.
- How to read a GTFS feed in Python read gtfs python
- How to find the trips running on a given date in GTFS gtfs trips on date
- How to map transit routes and stops from GTFS shapes map gtfs routes python
- How to calculate service frequency at every stop from GTFS gtfs stop frequency python
- How to clip a GTFS feed to a study area clip gtfs feed
- How to build walking catchments around transit stops transit stop walking catchment
- How to compute transit travel times from GTFS in Python transit travel time python gtfs
- How to draw a transit isochrone from a GTFS feed transit isochrone python
- How to measure the population served by frequent transit population near frequent transit
- How to read GTFS Realtime vehicle positions and delays in Python gtfs realtime python
- How to Animate Transit Vehicles from a GTFS Schedule in Python gtfs animation python
- How to Map Bike-Share Trips as Flows in Python bike share trips flow map python
- How to Build Desire Lines from Origin–Destination Data in Python desire lines python
- How to Measure Crime Around Transit Stations in Python crime near transit stations python buffer
🔧 When it breaks
The errors this topic produces, with the cause explained rather than just the command.
- GTFS times after 24:00 break time parsing gtfs time 24:00
- GTFS routes draw as straight lines between stops gtfs shapes straight lines
- A GTFS query returns no trips, or the wrong trips, on a date gtfs no trips on date
- Transit travel times come out too short transit travel time too short
- stop_times.txt is too big to load comfortably gtfs stop_times memory
Learning paths through this topic
A curated route rather than a list — the guides in the order that builds on itself.
Related topics
Subjects that keep coming up alongside this one, most overlap first.