GTFS Tables

2019-02-03

GTFS Table Relationships

gtfs-relationship-diagram Source: Wikimedia, user -stk.

Additional tables calculated by trread

In addition to the tables described above, trread attempts to calculate the following tables when one uses read_gtfs():

Frequencies/Headways

trread prints a message regarding these tables on reading any GTFS file.

Example GTFS Table Joins

Route Frequencies to Routes

For example, joining the standard routes table, with the ‘route_shortname’ variable to routes_frequencies_df.

Headways at Stops for a Route

A more complex example of cross-table joins is to pull the stops and their headways for a given route.

This simple question is a great way to begin to understand a lot about the GTFS data model.

First, we’ll need to find a ‘service_id’, which will tell us which stops a route passes through on a given day of the week and year.

When calculating frequencies, trread tries to guess which service_id is representative of a standard weekday by walking through a set of steps. Below we’ll just do some of this manually.

First, lets look at the calendar_df.

Then we’ll pull a random route_id and set of service_ids that run on Mondays.

Now we’ll filter down through the data model to just stops for that route and service_ids.