GTFS Routes, Trips & Stops Explained
Routes, trips, stops, and shapes form the geographic backbone of a GTFS feed. They describe where transit vehicles go, what path they follow, and where passengers can board. This guide explains each file in detail and shows how they connect to form a complete picture of a transit network.
routes.txt — defining transit lines
The routes.txt file defines the transit lines that an agency operates. Each route represents a group of trips that are displayed to riders as a single service — like "Bus 38" or "Red Line."
Key fields
| Field | Required | Description |
|---|---|---|
route_id | Yes | Unique identifier for the route |
agency_id | Conditional | Which agency operates this route (required if multiple agencies) |
route_short_name | Conditional | Short public-facing name (e.g., "38", "N", "Red") |
route_long_name | Conditional | Full descriptive name (e.g., "Geary Boulevard", "Judah") |
route_type | Yes | Mode of transport (bus, subway, tram, etc.) |
route_color | No | Hex color for display on maps (e.g., "FF0000") |
Route types
The route_type field classifies each route by vehicle mode. The most common values are:
| Value | Mode | Examples |
|---|---|---|
0 | Tram / Light Rail | Streetcars, light rail lines |
1 | Subway / Metro | Underground metro systems |
2 | Rail | Commuter rail, intercity trains |
3 | Bus | Regular bus service |
4 | Ferry | Passenger ferry services |
5 | Cable Tram | Cable cars, aerial tramways |
7 | Funicular | Steep-grade rail systems |
The extended GTFS route types specification includes more granular values (100s for rail subtypes, 200s for coach subtypes, etc.), but the basic values above cover most feeds.
The GTFS Viewer includes a Routes table where you can browse every route with its short name, long name, type, and agency — all sortable and searchable.
Example
route_id,agency_id,route_short_name,route_long_name,route_type,route_color
R001,sfmta,38,Geary,3,FF6600
R002,sfmta,N,Judah,0,1B9AD1
R003,sfmta,F,Market & Wharves,0,F0C832
trips.txt — individual journeys
While routes define transit lines, trips.txt defines individual journeys along those lines. A single route typically has dozens or hundreds of trips per day — one for each departure time in each direction.
Key fields
| Field | Required | Description |
|---|---|---|
trip_id | Yes | Unique identifier for this trip |
route_id | Yes | Which route this trip belongs to |
service_id | Yes | Which calendar defines when this trip runs |
trip_headsign | No | Destination sign displayed on the vehicle (e.g., "Downtown") |
direction_id | No | Direction of travel: 0 = outbound, 1 = inbound |
shape_id | No | Geographic path the vehicle follows |
The service_id field is crucial — it links each trip to the calendar files that define which days it operates. The shape_id links to shapes.txt to define the geographic path on the map.
Example
trip_id,route_id,service_id,trip_headsign,direction_id,shape_id
T38_001,R001,weekday,VA Medical Center,0,shape_38_out
T38_002,R001,weekday,Transbay Terminal,1,shape_38_in
T38_003,R001,weekend,VA Medical Center,0,shape_38_out
Notice how trips T38_001 and T38_002 share the same route (R001 = Bus 38) and service (weekday), but go in opposite directions with different headsigns and shapes.
stops.txt — where passengers board
The stops.txt file lists every physical location where passengers can board or exit a transit vehicle. Stops are shared across routes — a busy downtown stop might be served by a dozen different bus lines.
Key fields
| Field | Required | Description |
|---|---|---|
stop_id | Yes | Unique identifier for the stop |
stop_name | Yes | Public name of the stop |
stop_lat | Yes | Latitude (WGS84) |
stop_lon | Yes | Longitude (WGS84) |
location_type | No | 0 = stop/platform, 1 = station, 2 = entrance/exit |
parent_station | No | Station that contains this stop (for hierarchical stops) |
Stop hierarchies
For complex stations (like subway systems), GTFS supports a hierarchy: a station (location_type=1) contains multiple platforms (location_type=0) and entrances (location_type=2). The parent_station field links child stops to their parent station.
Example
stop_id,stop_name,stop_lat,stop_lon,location_type,parent_station
STN001,Powell Street Station,37.7844,-122.4080,1,
STN001_P1,Powell Street - Westbound,37.7844,-122.4081,0,STN001
STN001_P2,Powell Street - Eastbound,37.7843,-122.4079,0,STN001
S200,Geary & 25th Ave,37.7812,-122.4844,0,
Powell Street Station is a parent station with two platforms. Geary & 25th Ave is a simple bus stop with no parent.
TransitLens includes a dedicated Stops table where you can sort and search through all stops in the feed — useful for large feeds with thousands of entries.
Connecting stops to trips
Stops connect to trips through stop_times.txt, which defines the sequence of stops each trip visits and the arrival/departure times at each one. This is the largest file in most GTFS feeds — a single trip visiting 30 stops generates 30 rows.
shapes.txt — geographic paths
While stops define where vehicles pause, shapes.txt defines the actual path vehicles follow between stops. Without shapes, a map can only show straight lines between stops — with shapes, you see the real road or track geometry.
Key fields
| Field | Required | Description |
|---|---|---|
shape_id | Yes | Identifies which shape this point belongs to |
shape_pt_lat | Yes | Latitude of this shape point |
shape_pt_lon | Yes | Longitude of this shape point |
shape_pt_sequence | Yes | Order of this point in the shape |
A shape is defined as a series of latitude/longitude points that, when connected in sequence, trace the vehicle's path. More points means more geographic detail — curves in the road, loops around blocks, and highway ramps are all captured through dense point sequences.
Example
shape_id,shape_pt_lat,shape_pt_lon,shape_pt_sequence
shape_38_out,37.7749,-122.4194,1
shape_38_out,37.7751,-122.4180,2
shape_38_out,37.7752,-122.4165,3
shape_38_out,37.7755,-122.4140,4
shape_38_out,37.7812,-122.4844,50
shapes.txt is optional, but most modern feeds include it. Without shapes, route visualization is limited to stop-to-stop straight lines, which gives a misleading picture of the actual network geometry.
How they all connect
The four files work together through ID references to describe the complete geographic structure of a transit network:
Reading this diagram from left to right:
- A route has many trips (via
route_id) - Each trip visits a sequence of stops (via
stop_times.txt) - Each trip may follow a shape (via
shape_id) - The stops define where vehicles pause; the shape defines the path between pauses
This relational structure means a single stop can appear in thousands of stop_times rows (served by many trips on many routes), and a single shape can be shared by multiple trips that follow the same path.
Why visualization tools matter
Looking at these CSV files in a spreadsheet, you see rows of IDs, coordinates, and times. But load the same data into a visual tool, and the transit network materializes:
- Routes appear as colored lines on the map, following their shapes through streets and neighborhoods. You can instantly see coverage, density, and overlap.
- Stops appear as points at their geographic locations. Clicking a stop reveals which routes serve it and how frequently vehicles arrive.
- Trips become visible journeys — you can trace a single vehicle's path from start to finish, seeing every stop it makes along the way.
- Shapes reveal actual paths — without them, you'd only see straight lines between stops. With shapes, you see the real road geometry, including one-way loops, highway routing, and detours.
TransitLens renders all of these relationships on an interactive map. Upload a GTFS feed and you can browse routes by name, click on stops to inspect them, and see how the entire network connects geographically. It's the fastest way to understand how routes, trips, stops, and shapes work together in practice.
Learn more about all exploration capabilities — including data tables and calendar analysis — on the GTFS Viewer page, or see the GTFS Map Viewer for spatial analysis workflows.
Explore routes, trips & stops visually
Upload a GTFS feed and see every route, stop, and shape rendered on an interactive map.
Open TransitLens