You are in:  

GTFS: The backbone of Trip Planning Apps

A guide to GTFS icon

A detailed breakdown of the GTFS data format and a behind the scenes look into trip planning apps

If you’re responsible for making your transit data accessible to trip planners, mobility apps, or multimodal platforms, you’ve probably worked with GTFS (General Transit Feed Specification). On the surface, GTFS appears to be a collection of text files with CSV-formatted data. But it is actually a powerful relational data model that powers real-time rider experiences across hundreds of trip planning and transit apps.

A valid GTFS feed isn’t necessarily a good GTFS feed.

In this article, we’ll do a deep dive into the inner workings of GTFS: the information that each file contributes, how they interrelate, where agencies often run into trouble, and how to produce a robust feed that actually works in Google Maps, UseTransit, and other trip planning apps.

Facebook
Twitter
LinkedIn

GTFS Files: What's required, recommended, and advanced

These GTFS files are required and are the core of what powers trip planning apps.

 

File (Required)

Purpose

agency.txt

Metadata about your transit agency.

routes.txt

Public-facing info about route names, types.

trips.txt

Service runs (i.e. trips).

stop_times.txt

Timepoints for each trip.

stops.txt

All your transit agency’s fixed stops.

calendar.txt

Weekly service patterns by day of the week.

calendar_dates.txt

Exceptions to services for specific dates (e.g., holidays).

These GTFS files are optional and can enhance the info riders see when planning a trip. Note that trip planning apps may not support some or all of these features. 

File for real time transit data

Purpose

trip_updates.pb

Real-time delays, skipped stops, rescheduled trips.

vehicle_positions.db

Live GPS locations of transit vehicles in service.

alerts.pb

Transit alerts, such as detours, construction, weather notifications, etc.

 

File to improve trip planning

Purpose

frequencies.txt

Defines headway-based services (e.g., this trip runs every 10 minutes).

shapes.txt

Helps to draw the route or trip on a map.

File to improve fare information

Purpose

fare_attributes.txt

Defines fare price, currency, payment method, and rider categories.

fare_rules.txt

Links fares to zones, routes, or origin-destination stop pairs.

fare_products.txt

Describes individual fare products available for purchase.

Other files would be considered advanced and we’ll cover some of these in another article in our GTFS series – such as fare_media.txt, stop_areas.txt and others. 

GTFS File Data Diagram for Trip Planning Apps

It is important to know that there can be a lot of complexity, rules, and nuances when you are actually creating these files. Even if one of these relationships is broken – e.g., a trip_id references a missing route_id – the entire trip may be ignored by downstream platforms, or may not even pass basic validation checks.

 

GTFS.org is the authority on the GTFS data standard and should be used as the baseline reference. This image from GTFS.org nicely shows us how all the basic GTFS files are related to each other. Note that advanced files are not shown to keep things simple for now.

A data relationship diagram for the basic GTFS files.

Behind the scenes: How Trip Planning Apps use GTFS Data

We’ll illustrate how all these individual GTFS files come together using a practical example. In our example, we’ll use TransitFare Cloud and Google Maps, but the same concepts can be used with any other GTFS data producer and consumer pairing. 

  • TransitFare Cloud automatically generates the required GTFS files, packages them into a valid ZIP, and hosts that file at a stable, public URL.

  • Google Maps automatically downloads the latest GTFS data from that URL – usually once or twice per day, depending on how the feed is configured.

Once Google Maps has ingested and parsed the GTFS files, they then store the data internally to power their directions and trip calculations.

Now that Google has the GTFS data, Google Maps can generate multiple trip plans including transit as a trip mode:

  • Driving
  • Walking
  • Bicycling
  • Transit // trip plans here are powered by GTFS

Google Maps users will see all these trip options, then will select the option that works best.

In this example, we see it will take 29 minutes to get from a local grocery store (Mercato Fresh) to the Downtown Transfer Terminal. The GTFS data is powering these transit directions

The trip plan that Google shows under the 'transit' icon is powered by the GTFS data generated by TransitFare Cloud.

Digging deeper into what Google Maps is doing with GTFS data

Let’s keep digging deeper into what Google Maps is doing with the GTFS data generated by TransitFare Cloud when someone is planning their trip in Google Maps. The table below lists the steps that Google Maps might take when calculating out trip plans using transit. Notice all the key references back to the original GTFS data as trip options are being generated.

 

Step

Description

General GTFS Files Used

1. Validate Service

Check if the service_id is valid for today’s date based on the agency’s schedule, exceptions, and overrides.

calendar.txt, calendar_dates.txt

2. Locate Nearby Stops

Check stops.txt to locate all stops near the rider’s origin and destination (origin can be user input or current GPS location).

stops.txt

3. Find Valid Trips

Match trips that are running today using all valid service_ids, and look for relevant stop_times between the origin and destination.

trips.txt, stop_times.txt

4. Filter and Sort Trips

Rank all the available trips by departure time, trip duration, headway, number of transfers, walking distance, etc. Multiple trip options are typically presented to the user.

trips.txt, stop_times.txt

5. Map and Route Rendering

When the user selects a trip option, use the shape_id to draw the route path on a map and list all intermediate stops along the trip.

shapes.txt, stop_times.txt, stops.txt

6. Display to User

The selected trip plan is presented to the user through their interface (mobile, web, or tablet), including route, stops, timing, and walking guidance.

 

The screenshot below shows how all of these steps come together and are displayed to a user in Google Maps, when viewing a trip plan using transit. These steps typically happen in less than a second

Notice all the trip details, such as:

  • Departure and arrival times.
  • Detailed walking directions to the transit stops
  • A map showing the route.
  • How frequently the trip is serviced.

A detailed example showing how GTFS data is presented in Google Maps when viewing a trip plan.

GTFS Data Publishing with TransitFare Cloud

TransitFare Cloud automates the whole process of creating, managing and publishing GTFS data. As a result, agencies can devote more resources to improving rider experiences rather than getting bogged down by the technical details of managing transit data. 

Centralizing Transit Data in TransitFare Cloud

Centralizing transit data management in a platform like TransitFare Cloud offers numerous benefits for public transit systems. When all transit data is managed in one central location, it becomes easier to manage since it is all in one place. 

Automated GTFS Hosting and Publishing

TransitFare Cloud automatically hosts and publishes your latest GTFS transit data to all the mapping apps, trip planning apps, and other systems that you’ve authorized. It provides stable, 24/7 access to your transit data, so that riders are able to plan their trips on any device. 

Additional Reading

The following additional reading materials on this topic have been provided for your convenience. These are external links and will open the article in a new browser tab. Accessing and utilizing these links is solely at your own risk. We advise you to carefully review their terms and privacy policies before use, as we do not bear responsibility for the content found on these external sites.

Get TransitFare Cloud to publish Your GTFS Data