Skip to content

GTFS

General Transit Feed Specification (GTFS) is a digital exchange format developed by Google for timetables used for public passenger transport services and relevant geographical information, such as locations of stops. Data is supplied by transport companies and published as an accumulated database in GTFS format on the Open Data Platform Swiss Public Transport. The data is used to develop applications relating to public transport, such as timetable queries.

Unlike GTFS Realtime (GTFS RT), GTFS Static, as the name suggests, only provides static data and no real-time data.

This static file is first used to present a country’s entire public transport operation in a single feed.

Technical description

GTFS Static is provided in ZIP format using a series of text files. Each file provides information about a particular aspect of the transit information, for instance, stops (stops.txt), routes (routes.txt), journeys (trips.txt), transport companies (agency.txt) and other timetable-related data. Some information is required to provide valid GTFS data, while other information is optional and provides useful additional information (e.g. changes to the timetable on specific public holidays = calendar_dates.txt).

The diagram below illustrates how the different types of information interact, showing that, at present, not all information has been recorded for public transport in Switzerland and is available in GTFS Format.

Klassen GTFS Static

GTFS Static classes

Access the relevant dataset at: https://opentransportdata.swiss/de/dataset/timetable-2021-gtfs2020

Key concepts

  • GTFS Realtime Publication of static transit information in GTFS format.
  • GTFS Realtime: Publication of real-time information to enhance the static GTFS Data, in the form of protocol buffers.

Technical aspects

Data structure

Each file comprises comma-separated rows of texts and numbers, which combine to provide the information being sought. A comprehensive description is provided of the individual fields in the various files on the following website: https://developers.google.com/transit/gtfs/reference/

The following files are currently provided for the GTFS export for public transport in Switzerland:

  • agency.txt.
  • calendar.txt.
  • calendar_dates.txt
  • feed_info.txt
  • routes.txt
  • stop_times.txt
  • stops.txt
  • transfers.txt being (being drafted)
  • trips.txt

The following are not available: fare_attributes.txt, fare_rules.txt, feed_info.txt and frequencies.txt

Agency.txt.

calendar.txt

calendar_dates.txt

feed_info.txt

routes.txt

Please note:

  • Some routes in GTFS have an extension “-Y”. The reason for this is that they have a line number which has been created artificially. This is the only way that “route_short_name” can be valid. These artificial lines should therefore not be shown to users. In the case of trains, “trip_short_name” will include the train number.

The means of transport texts which are used (the variable route_desc contains informationen of the column “Abbreviation”):

Abbreviation DE FR IT EN Ref_TransportMode route_type
ASC Aufzug Ascenseur Ascensore Lift / Elevator A 1700
B Bus Autobus Autobus Bus B 700
BN Nachtbus Bus de nuit Autobus notturno Night Bus B 705
BP PanoramaBus Bus panoramique PanoramaBus Panorama Bus B 710
BUS Bus Autobus Autobus Bus B 700
CAR Fernbus national Bus longue distance national Autobus nazionale a lunga percorrenza National long-distance bus B 202
CAX Fernbus international Bus grandes lignes international Autobus a lunga percorrenza internazionale International long-distance bus B 201
EB Eilbus Bus express Autobus espresso Semi fast bus B 702
EXB Expressbus Expressbus Expressbus Express bus B 702
ICB InterCity-Bus Bus InterCity Autobus InterCity InterCity Bus B 202
KB Kleinbus Minibus Furgoncino Minibus B 700
NB Nacht-Bus Bus de nuit Bus notturno Night Bus B 705
NFB Niederflur-Bus Bus à plancher surbaissé Bus a pianale ribassato Low-floor bus B 700
NFO Niederflur-Trolleybus Trolleybus à plancher surbaissé Filobus a pianale ribassato Low-floor trolley bus B 700
RUB Rufbus Bus sur appel Bus a chiamata On-demand Bus B 715
TX Taxi Taxi Tassì Taxi B 1500
SL Sesselbahn Télésiège Seggiovia Chairlift E 1300
CC Zahnradbahn Chemin de fer à crémaillère Ferrovia a cremagliera Rack-railroad / Cog Railway H 1400
GB Gondelbahn Télécabine Ovovia Gondola lift L 1300
LB Luftseilbahn Téléphérique Funivia Cableway / Aerial Ropeway L 1300
PB Pendelbahn Téléphérique à mouvement de va-et-vient Funivia a movimento va e vieni Aerial Tramway L 1300
M Metro Métro Metropolitana Underground / Metro M 401
FUN Standseilbahn Funiculaire Funicolare Funicular N 1400
BAT Schiff Bateau Battello Ship / Boat S 1000
BAV Dampfschiff Bateau à vapeur Battello a vapore Steam ship / boat S 1000
FAE Fähre Traversier / Ferry Nave traghetto Ferry S 1000
KAT Katamaran Catamaran Catamarano Katamaran S 1000
NFT Niederflur-Tram Tram à plancher surbaissé Tram a pianale ribassato Low-floor Tramway T 900
T Tram Tram Tram Tram T 900
TN Nachttram Tram de nuit Tram notturno Night Tram T 900
AIR Flugzeug Avion Velivolo Airplane U 1100
UUU Unbekannte Art Espèce inconnue Specie sconosciuta Unknown mode U 1700
AG Agenturzug Train de l’agence Treno d’agenzia Agency Train Z 117
ARC Arco  ARCO ARCO Arco Z 102
ARZ Autoreisezug Train d’autos accompagnées Treno auto accompagnate Car-carrying Train Z 104
AT Autotunnelzug Train-autos Tunnel Treno per il trasporto di auto in galleria Auto Tunnel Train Z 104
ATR Altaria Altaria Altaria Altaria Z 102
ATZ Autotunnelzug Train-autos Tunnel Treno per il trasporto di auto in galleria Auto Tunnel Train Z 104
AVE Alta Velocidad ES Alta Velocidad ES Alta Velocidad ES Alta Velocidad ES Z 101
BEX Bernina Express Bernina Express Bernina Express Bernina Express Z 107
CAT City Airport Train City Airport Train Treno città-aeroporto City Airport Train Z 111
CNL CityNightLine CityNightLine CityNightLine CityNightLine Z 105
D Schnellzug Train Express Treno espresso Fast Train Z 103
E Eilzug Train accéléré Treno espresso Semi fast / non-stop Train Z 103
EC EuroCity EuroCity EuroCity EuroCity Z 102
EM Euromed Euromed Euromed Euromed Z 102
EN EuroNight EuroNight EuroNight EuroNight Z 105
ES Eurostar Italia Eurostar Italia Eurostar Italia Eurostar Italia Z 101
EST Eurostar Eurostar Eurostar Eurostar Z 101
EXT Extrazug Train spécial Treno speciale Special Event Train Z 117
GEX Glacier Express Glacier Express Glacier Express Glacier Express Z 107
IC InterCity InterCity InterCity InterCity Z 102
ICE InterCityExpress InterCity-Express InterCityExpress InterCityExpress Z 102
ICN IC-Neigezug Train pendulaire IC Treno basculante IC IC Tilting Train Z 102
IN InterCityNacht Nuit InterCity InterCityNight InterCityNight Z 102
IR InterRegio InterRegio InterRegio InterRegio Z 103
IRE Interregio-Express InterregioExpress Interregio-Express Interregio-Express Z 103
IT Italo Italo Italo Italo Z 102
JAT Gefängniszug Train-prison Treno della prigione Jail / Prison Train Z 111
MAT LeermaterialZug (Reisezugswagen) Train de matériel vide (voiture de voyageurs) Treno vuoto (carrozze passeggeri) Empty material train (passenger carriage) Z 111
MP LeermaterialZug Personenbeförd Train de matériel vide Transport de personnes Treno materiale vuoto Trasporto passeggeri Empty material train with passenger transport Z 111
NJ NightJet NightJet Nightjet NightJet Z 105
NZ Nacht-Zug Train de nuit Treno notturno Night Train Z 105
P Zug ohne Gewähr Train non garanti Treno senza garanzia Train without Guarantee Z 100
PE PanoramaExpress PanoramaExpress PanoramaExpress PanoramaExpress Z 107
R Regio Train régional Regio Regio Z 106
RB Regionalbahn Réseau régional Ferrovia regionale Regional train Z 106
RE RegioExpress RegioExpress RegioExpress RegioExpress Z 106
RJ Railjet Railjet Railjet Railjet Z 102
RJX railjet xpress Railjet Xpress Railjet Xpress Railjet Xpress Z 102
S S-Bahn RER Rete celere regionale Urban Train Z 109
SN Nacht-S-Bahn RER de nuit S-Bahn (rete celere regionale) notturna Night-urban Train Z 109
STB Stadtbahn Chemin de fer urbain Ferrovia urbana City Railway Z 109
TAL Talgo Talgo Talgo Talgo Z 101
TER Train Express Regional Train Express régional Treno espresso regionale Train Express Regional Z 106
TE2 TER200 TER 200 TER200 TER200 Z 106
TGV Train à grande vitesse Train à grande vitesse Train à grande vitesse Train à grande vitesse Z 101
THA Thalys Thalys Thalys Thalys Z 101
TLK Twoje Linie Kolejowe Deuxième Ligne Kolejowe Linea Twoje Kolejowe Twoje Line Kolejowe Z 102
UEX UrlaubsExpress UrlaubsExpress HolidayExpress UrlaubsExpress (Holiday) Z 104
VAE Voralpen-Express Voralpen-Express Voralpen-Express Voralpen-Express Z 103
WB Westbahn Westbahn Westbahn Westbahn Z 100
X InterConnex InterConnex InterConnex InterConnex Z 100
X2 X2000 Neigezug X2000 Train pendulaire Treno inclinabile X2000 X2000 Tilting Train Z 100
ZUG Zugskategorie unbekannt Catégorie de train inconnue Categoria del treno sconosciuta Train Category Unknown Z 100

stop_times.txt

stops.txt

The platforms must be modelled in GTFS as individual stops. Replacing the platform is then the same as replacing the stop from a GTFS perspective.

x2123

 

Example using “8500010” (Basel SBB):

basel

All the stops in Basel have a common “parent” “8500010P”. The individual platforms are separated by “:”. A “platform” can also be a platform+sectors (e.g. “8500010:0:7CD”). There are also very strange additions, such as “Bern Bfpl”, giving “8507000:0:Bfpl” if the RBS uses it for rail replacement buses.

trips.txt

Please note:

  • In the case of trains, “trip_short_name” will include the train number.
  • A “trip” according to GTFS represents in Transmodel the concept of a “DatedVehicleJourney” (in OJP a “DatedJourney”).  In Transmodel and OJP a TRIP is a journey of the customer as returned by the Trip Planner. It consists of different partial journeys, interchanges and other paths to be covered with different modes. In HRDF the GTFS ‘trip’ corresponds to the journey and in NeTEx to the ServiceJourney.

transfers.txt

The metastations will soon be presented in transfers.txt.

Consistency in terms of identifying between versions of the static file

The GTFS Static is recreated every week. This means that the “service_id” and the “trip_id” may not be identical.

When are there new GTFS Static files?

The new HRDF is published on Mondays.

The GTFS upload is carried out via script on Wednesdays at 09:10. The GTFS-RT feed downloads the files at 14:00 via script. It then takes about 5-10 minutes before the files in the system and, therefore, the GTFS-RT feed are switched.

Internal consistency of a GTFS Static file

We make every effort to produce correct GTFS Static files. Google suggests testing the internal consistency using the FeedValidator. Unfortunately, the current version is unable to cope with the size of our file. Another tool that can be used is gtfstidy, which includes among its functions the option to carry out validation using the parameter “-v”

 

Questions & answers

What do the first and last two sections of the trip_id mean? E.g. {405}.TA.26-752-j17-1.{3}.{R} The trip_id consists of the following parts: “<consecutive number in trips.txt>.<service_id>.<route_id>.<DIVA route number>.<DIVA direction of travel>”

route_id = <DIVA branch of operation>-<DIVA line number>-<DIVA project abbreviation>-<DIVA line version number>

What is the Trip ID made up of? The trip ID is made up of different DIVA numbers/fields and has nothing to do with the HRDF data.

The assignment is not quite 1:1, as the journey ID (= journey number) does not have to be unique within an HRDF data set, but with the help of stops and stop times, as the data user has done, the matching journey can be found as follows::

The trips.txt contains the trip_short_name:

route_id,service_id,trip_id,trip_headsign,trip_short_name,direction_id

“26-94-j18-1″,”TA+b20xg”,”310.TA.26-94-j18-1.3.R”,”Zürich Oerlikon, Bahnhof”,”13628“,”1”

 

This corresponds to the journey number (external train number) in the *Z line of the FPLAN file:

unbenannt

As the journey number does not have to be unique within an HRDF feed, the stop times and stop_ids of the journey from the stop_times.txt should also be used for assignment:

 

trip_id,arrival_time,departure_time,stop_id,stop_sequence,pickup_type,drop_off_type

“310.TA.26-94-j18-1.3.R”,”13:37:00″,”13:37:00″,”8587651″,”1″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:38:00″,”13:38:00″,”8587652″,”2″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:39:00″,”13:39:00″,”8591263″,”3″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:41:00″,”13:41:00″,”8591347″,”4″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:42:00″,”13:42:00″,”8591047″,”5″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:43:00″,”13:43:00″,”8591113″,”6″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:44:00″,”13:44:00″,”8591330″,”7″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:45:00″,”13:45:00″,”8591319″,”8″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:46:00″,”13:46:00″,”8591175″,”9″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:46:00″,”13:46:00″,”8591273″,”10″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:48:00″,”13:48:00″,”8591382″,”11″,”0″,”0″

“310.TA.26-94-j18-1.3.R”,”13:49:00″,“13:49:00″,”8580449”,”12″,”0″,”0″

The HRDF feed two days later (e.g. 05/02/2018) always matches the GTFS feed (e.g. 07/02/2018):

unbenannt

Further information