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/dataset/timetable-2017-gtfs

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:

  • “route_short_name” will soon be changed again and will contain an internal representation of the type of means of transport.
  • 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 will be used (not yet implemented):

Verkehrsmitteltexte

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.

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”

More detailed information

You can find more detailed information about GTFS Static on Google’s GTFS developer website: https://developers.google.com/transit/gtfs/

Start the discussion at disc.opentransportdata.swiss