Product Features Why TransitLens Guides

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

FieldRequiredDescription
route_idYesUnique identifier for the route
agency_idConditionalWhich agency operates this route (required if multiple agencies)
route_short_nameConditionalShort public-facing name (e.g., "38", "N", "Red")
route_long_nameConditionalFull descriptive name (e.g., "Geary Boulevard", "Judah")
route_typeYesMode of transport (bus, subway, tram, etc.)
route_colorNoHex 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:

ValueModeExamples
0Tram / Light RailStreetcars, light rail lines
1Subway / MetroUnderground metro systems
2RailCommuter rail, intercity trains
3BusRegular bus service
4FerryPassenger ferry services
5Cable TramCable cars, aerial tramways
7FunicularSteep-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

FieldRequiredDescription
trip_idYesUnique identifier for this trip
route_idYesWhich route this trip belongs to
service_idYesWhich calendar defines when this trip runs
trip_headsignNoDestination sign displayed on the vehicle (e.g., "Downtown")
direction_idNoDirection of travel: 0 = outbound, 1 = inbound
shape_idNoGeographic 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

FieldRequiredDescription
stop_idYesUnique identifier for the stop
stop_nameYesPublic name of the stop
stop_latYesLatitude (WGS84)
stop_lonYesLongitude (WGS84)
location_typeNo0 = stop/platform, 1 = station, 2 = entrance/exit
parent_stationNoStation 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

FieldRequiredDescription
shape_idYesIdentifies which shape this point belongs to
shape_pt_latYesLatitude of this shape point
shape_pt_lonYesLongitude of this shape point
shape_pt_sequenceYesOrder 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:

routes.txt
route_id route_short_name route_type
route_id
trips.txt
trip_id route_id service_id shape_id
trip_id
stop_times.txt
trip_id stop_id arrival_time stop_sequence
stop_id
stops.txt
stop_id stop_name stop_lat stop_lon
shape_id
shapes.txt
shape_id shape_pt_lat shape_pt_lon shape_pt_sequence

Reading this diagram from left to right:

  1. A route has many trips (via route_id)
  2. Each trip visits a sequence of stops (via stop_times.txt)
  3. Each trip may follow a shape (via shape_id)
  4. 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:

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