How Does a GTFS Dataset Describe Transit Service?
From the earlier reference collection. Read the current software blog.
GTFS separates an agency’s identity, its routes and trips, the stops they serve, and the dates and times when service runs.
Start with the agency and route
A GTFS schedule dataset describes transit through related tables rather than one record per passenger journey. The agency.txt file identifies the transit organization and provides context for the feed. The routes.txt file describes the services a rider can recognize as routes, such as a numbered bus line or a named rail service. Each route has an identifier that other records can refer to; its displayed name and other attributes help a consumer present it.
Trips connect routes to stops
A route can operate many trips: individual scheduled runs along a sequence of locations. The trips.txt file associates a trip with its route and, among other details, a service identifier. The stop_times.txt file then gives the ordered stop-level schedule for each trip. The stops.txt file supplies the locations themselves, including identifiers and location information. Together, the trip and stop-time records answer a more precise question than “What is the route?”: which scheduled run visits which stops, and in what order?
For example, imagine route R7 with a morning trip T42. The route record gives the rider-facing service identity; T42 refers to R7; and T42’s stop-time rows might list stop S1 at 07:10, S2 at 07:18, then S3 at 07:31. The stop records provide the names and coordinates associated with S1, S2, and S3. These identifiers allow a consumer to join the information without relying on matching text labels.
Calendars determine when a trip runs
A service identifier is not itself a date. The calendar.txt file describes recurring weekly service over a date range, while calendar_dates.txt can add or remove service on particular dates. A trip’s service identifier links it to that calendar information. To decide whether T42 is scheduled for a particular day, a consumer needs both the trip’s service association and the applicable calendar records. The GTFS reference explains these files and defines a service day as an agency-dependent period that may extend past midnight.
Read the dataset as a chain of references
A practical inspection follows the references: identify an agency, find a route, select a trip on that route, check its ordered stop times, resolve each stop, and determine the service dates. This chain is useful when a feed appears inconsistent. If a trip has no matching route or service record, the issue is different from a valid trip that simply does not run on the date being queried. Thinking in these linked layers makes schedule data easier to validate and explain.