Skip to content

Create routable network from GTFS files

Jip Claassens edited this page May 26, 2025 · 5 revisions

Back to Public transport simulation

Reading GTFS text files

  • Agency: Transit agencies with service represented in this dataset.
  • Calendar: Service dates specified using a weekly schedule with start and end dates.
  • Calendar dates: Exceptions for the services defined in the calendar.txt.
  • Routes: Transit routes. A route is a group of trips that are displayed to riders as a single service.
  • Shapes: Rules for mapping vehicle travel paths, sometimes referred to as route alignments.
  • Stop times: Times that a vehicle arrives at and departs from stops for each trip.
  • Stops: Stops where vehicles pick up or drop off riders. Also defines stations and station entrances.
  • Trips: Trips for each route. A trip is a sequence of two or more stops that occur during a specific time period.

Creating the network

The GTFS files contain a lot of information, but not everything is relevant for the current analysis. For example, you have to choose an analysis date. We use that date, plus the following day, for the analysis. We create the so-called protoStops from the original stop set, wherein the WGS84 coordinates are converted into Dutch Rijksdriehoek coordinates. Moreover, we create an attribute which, based on the dates, determines where the stop is used in that time window. Similarly, we create a protoStopTimes in which we relate the stops and trips, select the relevant time window, determine the next stop, and relate the used modality. Here, we also create links that have a stop_rel and departure time, as well as a stop_rel and arrival time. These links culminate in the so-called scheduled links, which are the basis of the public transport network. In here we have all the relevant link information, e.g. from/to stop_rel, from/to time_rel, mode_rel, route_rel, agency_rel, length, duration). In order to obtain the unique set of space-time-events, we union the fromTime_Stop_rel with the toTime_Stop_rel and take the unique values. Which will later be used to create the full place set (together with the origins and destinations).

Now that we have a linkset and node set with all relevant attributes, we need to make it routable. We now only have links with its nodes and departure and arrival times. In most cases, these will not overlap with the following link on a trip. A traveller, for example, will have to wait inside the train when it stops before continuing its trip. So we need to add waiting-at-stop between those links. We achieve this goal by creating a trip-time identifier that has all departure and arrival times for each trip (which is a time-specified route). To do this, take the unique values and enrich them with all necessary attributes. And create links with the calculated necessary duration. We then union this waiting linkset with the scheduled links. This is now a fully routable public transport network.

Clone this wiki locally