Skip to content

HAFAS Raw Data Format (HRDF)

The timetable data is supplied on the Open Data Platform in two formats. GTFS and HAFAS Raw Data Format (HRDF).

Functional description

The HRDF file contains all the master data for understanding a timetable and the timetables for public transport in Switzerland.

Key concepts

Distinction

The HRDF file only includes public transport in Switzerland. International trains are (in most cases) terminated at the first commercial stop abroad. The reality is, of course, is that they continue their journey. In some cases, the international journey terminates at the last stop in Switzerland (e.g. Geneva) or includes another 1-2 stops/operating points abroad.

The file for public transport in Switzerland also includes the network map for SBB GmbH in Germany. There are ultimately historical reasons for this.

Who should use HRDF

HRDF files are relatively complex. Therefore, they should not be used unnecessarily.

Example 1: Extract from BITFELD file:

000017 FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000
000001 DF3870F9F3E7CF9F3E7CF9F3E7CF0F3E7CF1F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000003 DF3060F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79D3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000005 DF3870F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF8F3E7CF9F3E7CF9F3E7CFB0000
000006 DF3060F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000007 DF3874F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000010 DF3870F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000011 D02040810204081020408102040810204081020408102040810204081020408102040810204081020408102040830000
000014 DE3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F30000
000015 DF3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000016 DFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFDFBF7EFF0000
000018 DF3874B9F3E7CF9F3E7CF9F3A7CF8F3E7CF1F3A7C79D3E7CF8F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CBB0000
000020 DF3870F9F3E7CF9F3E7CF9F3E7CF0F3E7CF9F3A7C79D3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CBB0000
000021 DF3874F9F3E7CF9F3E7CF9F3E7CF0F3E7CF1F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000023 CC183060C183060C183060C183060C183060C183060C183060C183060C183060C183060C183060C183060C1830630000
000025 CF1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C7B0000
000026 CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7F0000
000028 DF3060F9F3E7CF9F3E7CF9F3E7CF0F3E7CF1F3A7C79F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CFB0000
000031 DF3870F9F3E7CF9F3E7CF9F3A7CF8F3E7CF9F3A7C79D3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CF9F3E7CBB0000
000033 C40810204081020408102040810204081020408102040810204081020408102040810204081020408102040810230000
000036 C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3C78F1E3F0000
000044 C20408102040810204081020408102040810204081020408102040810204081020408102040810204081020408130000
000050 C181020C183060C183060C1830604183060C183060C183060C183060C103060C183060C183060C183060C183060F0000
000051 E1C78F0E1C3870E1C3870E1C3870F1C3870E1C7878E1C3870E1C3870E1C3870E1C3870E1C3870E1C3870E1C3870F0000
000055 C102040810204081020408102040810204081020408102040810204081020408102040810204081020408102040B0000

This file contains bitmaps which are used to determine on which day a form of transport is operating.

Example: Extract from BFKOORD_GEO file:

8500171   7.083444  47.224238 1011   % Les Reussilles
8500172   7.025194  47.220364 1006   % La Chaux-des-Breuleux
8500173   7.005155  47.210432 1020   % Les Breuleux
8500174   6.956854  47.223678 969    % Le Noirmont
8500175   6.940645  47.203460 1013   % Le Creux-des-Biches
8500176   6.922098  47.194240 1033   % Le Boéchet
8500177   6.906172  47.176897 1029   % Les Bois
8500178   6.894529  47.142688 1005   % La Ferrière
8500179   6.883655  47.122118 1036   % La Cibourg
8500180   6.896700  47.161255 1016   % La Large-Journée
8500181   6.898712  47.152719 994    % La Chaux-d'Abel
8500184   6.837161  47.103480 1012   % La Chaux-de-Fonds-Est
8500186   7.128333  47.424135 450    % Alle
8500187   7.156649  47.452540 448    % Vendlincourt
8500188   7.155394  47.473978 437    % Bonfol
8500189   7.590844  47.544273 288    % Basel Solothurnerstrasse

This file contains the stops’ coordinates. The name of the stop is only contained in a “Comment” field.

Technical aspects

HRDF is a relatively old format. The individual text files are roughly similar to individual tables in a relational database. However, the individual parts can have varying content.

Data structure

The HRDF file is a ZIP file which contains ASCII files. The Latin-1 character set is used. They are not CSV files, but the old-fashioned fixed-length fields, which means that different lines can have different content.

To a certain extent, the HRDF file can be viewed as a database dump. The individual files in the ZIP correspond to individual tables or objects.

Description

It is a good idea to read the complete description carefully about how to use HRDF files. You can find out more in this PDF: hrdf.

From the end of January 2017, an extension will be used to generate the files, which is described here: Komm-HR16_D_Erweiterungen-bei-HRDF.pdf.

There are now a number of special topics discussed below.

Means of transport

In HRDF the means of transport are contained in the “ZUGART” file. The detailed information is contained in the first section. Columns 1-3 feature the short name and columns 5-6 contain the product class (0-13).

The second section contains classes (for grouping types), options (search) and categories (names of types). The whole thing is output in different languages.

...
<text>
<Deutsch>
class00 ICE/EN/CNL/CIS/ES/MET/NZ/PEN/TGV/THA/X2
class01 EuroCity/InterCity/ICN/InterCityNight/SuperCity
class02 InterRegio
class03 Schnellzug/RegioExpress
class04 Schiff/Fähre/Dampfschiff
class05 S-Bahn/StadtExpress/Eilzug/Regionalzug
class06 Bus/Kutsche/Taxi
class07 Luftseilbahn/Standseilbahn/Gondelbahn/Sesselbahn
class08 Metro/Autoreisezug/Extrazug/UrlaubsExpress
class09 Tram
option10 nur Direktverbindungen
option11 Direkt mit Schlafwagen*
option12 Direkt mit Liegewagen*
option13 Veloselbstverlad zugelassen (nur Schweiz)
option14 Gruppenbeförderung zugelassen (nur Schweiz)
category001 Agenturzug
category002 Flugzeug
category003 Alaris
category004 Alvia
category005 Arco
category006 Autoreisezug
category007 Altaria
category008 Autotunnelzug
category009 Avant
category010 Alta Velocidad ES
category011 Schiff
category012 Dampfschiff
category013 Bernina Express
category014 Bus
category015 City Airport Train
category016 CityNightLine
category017 Schnellzug
category018 Eilzug
category019 Eilbus
category020 EuroCity
category021 Euromed
category022 EuroNight
category023 Eurostar Italia
category024 Eurostar
category025 IC Bus
category026 Extrazug
category027 Fähre
category028 Standseilbahn
category029 FYRA Schnellzug
category030 Gondelbahn
category031 Glacier Express
category032 InterCity
category033 InterCity-Bus
category034 InterCityExpress
category035 IC-Neigezug
category036 InterCityNacht
category037 InterRegio
category038 Interregio-Express
category039 Italo
category040 Jail train 
category041 Katamaran
category042 Kleinbus
category043 Pferdekutsche
category044 Luftseilbahn
category045 Metro
category046 LeermaterialZ Personenbeförd
category047 Nacht-Bus
category048 Niederflur-Bus
category049 Niederflur-Trolleybus
category050 Niederflur-Tram
category051 Nacht-Zug
category052 ÖBB EuroCity
category053 ÖBB InterCity
category054 Zug ohne Gewähr
category055 Regio
category056 Regionalbahn
category057 RegioExpress
category058 Railjet
category059 Regio-S-Bahn
category060 S-Bahn
category061 Schul-Bus
category062 Sesselbahn
category063 Nacht-S-Bahn
category064 Stadtbahn
category065 Stadtbahn Zürich
category066 Tram
category067 Talgo
category068 TER200
category069 Train Express Regional
category070 Train à grande vit.
category071 Thalys
category072 Twoje Linie Kolejowe
category073 Trolleybus
category074 Taxi
category075 UrlaubsExpress
category076 Unbekannte Art
category077 Voralpen-Express
category078 Westbahn
category079 InterConnex
category080 X2000 Neigezug
category081 Zugskategorie unbekannt
<Englisch>
...

Although “<>” tags are used, it is not XML format.

Extracting offers from HRDF

An offer is used to describe a service or customer-related attribute of the means of transport (e.g. minibar). Offers can be valid for the whole of the means of transport’s operation or for parts of it.

The offers are fixed as attributes in HRDF in the files “ATTRIBUT_DE”, “ATTRIBUT_EN”, “ATTRIBUT_FR” and “ATTRIBUT_IT”:

RZ 0   4  8 Ruhezone in 1. Klasse#
SB 0   2  1 Spezialbillette#
SC 0   2  5 Starbucks#
SD 1   0  2 Halt nur zum Aussteigen#
SH 1   0  7 Saisonale Haltestelle#
SM 1   0  2 Halt nur zum Einsteigen#
SN 0   7  3 SnackPoint#
SZ 0   2  1 Besonderer Fahrschein oder Zuschlag erforderlich#
TF 0   3  1 Weitere Verbindungen: siehe www.fahrplanfelder.ch#
TG 0   3  1 OHNE GEWÄHR: siehe www.fahrplanfelder.ch#
TS 0   1  1 Zusatzzug#
TT 0   1  1 Neigezug#
VL 0   6  5 VELOS: Selbstverlad eingeschränkt#
VN 0   6  5 VELOS: Kein Selbstverlad#
VP 0   6  6 VELOS: Reservierung, siehe www.postauto.ch#
VR 0   6  6 VELOS: Reservierung obligatorisch#
VX 0   6  6 VELOS: Beförderung nicht möglich#
WL 0   5  1 Schlafwagen#
WR 0   1  4 Restaurant#
WS 0   2  4 Bistro#
X  1   0  1 Halt auf Verlangen#
XP 1   7  0 Einstieg nur mit Reservierung, siehe www.postauto.ch#
XR 1   0  7 Einstieg nur nach telefonischer Voranmeldung#
XT 1   0  7 Einstieg nur mit Reservierung, siehe www.fahrplanfelder.ch#

A dining car is given the attribute code “WR”. Attributes can also be used for stops. The “*A” lines in “METABHF” are an example of this.

In specific terms, a dining car in an “*A” line is used in the actual timetable file “FPLAN”:

8504371 Biel/Bienne BSG       01430                       % 00070 000182   002 (015)
*Z 00071 000182   001                                     % 00071 000182   001 (001)
*G BAT 8504371 8504378  01400  01515                      % 00071 000182   001 (002)
*A VE 8504371 8504378 004098  01400  01515                % 00071 000182   001 (003)
*A 2  8504371 8504378         01400  01515                % 00071 000182   001 (004)
*A WR 8504371 8504378         01400  01515                % 00071 000182   001 (005)
*R

This applies to the dining car:

  • Is included from Stop “8504371” (Biel/Bienne).
  • Until Stop “8504378”.
  • There is space for a bitmap of the days on which the attribute is valid. If the information is not provided, as in this case, this applies to every day.
  • Departure time (14:00)
  • Arrival time (15:15)
  • The comments are not broken down here (everything after “%”).

Extracting lines from HRDF

A line is a key concept in public transport in Switzerland. You can find out more about it in Journey ID.

Lines are used directly in the file “FPLAN”. Please note that lines are not globally unique. They are unique for each type of administration (=business organisation).

In “FPLAN” the “*L” line is the source for the line number.

The first field indicates the line number:

*Z 00007 000801   010                                     % 00007 000801   010 (001)
*G BUS 8572840 8572859  01047  01109                      % 00007 000801   010 (002)
*A VE 8572840 8508780 000020  01047  01102                % 00007 000801   010 (003)
*A VE 8508780 8572859 003088  01102  01109                % 00007 000801   010 (004)
*A SD 8572854 8572858 003088  01103  01107                % 00007 000801   010 (005)
*I RN                        0118655                      % 00007 000801   010 (006)
*L 221      8572840 8572859  01047  01109                 % 00007 000801   010 (007)
*R                                                        % 00007 000801   010 (008)
8572840 Wolhusen, Bahnhof            01047                % 00007 000801   010 (009)
8572841 Wolhusen, Post        01048  01048                % 00007 000801   010 (010)
8572843 Wolhusen, Viadukt     01049  01049                % 00007 000801   010 (011)
8572844 Wolhusen, Markt       01050  01050                % 00007 000801   010 (012)
8572845 Wolhusen, Emsern      01051  01051                % 00007 000801   010 (013)

In this case, we have line “221”.

The “*Z” line (and also the comments) tell us that journey number “000007” and business organisation “801” (PAG, i.e. Postauto) are involved.

Calendar/Bitmap days

Refer to the page on the subject Calendar.

Interchanges in HRDF

Some interchanges are contained in the metastations (see below).

Other relevant aspects are contained in other different files:

“UMSTEIGB”:

  • Stop number
  • Interchange time IC-IC
  • Interchange time for all others
  • (optional) Plain text for stop name
8502995 01 01 Neuheim, Post
8502998 01 01 Sursee, Bahnhof
8503000 07 07 Zürich HB
8503001 03 03 Zürich Altstetten
8503003 04 04 Zürich Stadelhofen
8503004 03 03 Zürich Tiefenbrunnen
8503006 03 03 Zürich Oerlikon
8503010 03 03 Zürich Enge
8503011 03 03 Zürich Wiedikon

“BFPRIOS”:

  • The interchange priority for the relevant station is defined in this file.

“UMSTEIGV”:

  • It may be important that at particular stops there has to be a switch between two business organisations. The relevant times are saved in “UMSTEIGV”.
8576274 000773 000773 01 Hüttikon
8576274 000773 000882 01 Hüttikon
8576274 000807 000807 01 Hüttikon
8576274 000807 000882 01 Hüttikon
8576274 000882 000773 01 Hüttikon
8576274 000882 000807 01 Hüttikon
8576274 000882 000882 01 Hüttikon

“UMSTEIGL”:

  • Similar to “UMSTEIGV” but for lines.
8594089 000889 NFB 8        1 000889 NFO 4        1 001  Nidau, Bahnhof
8594089 000889 NFB 8        2 000889 NFO 4        1 001  Nidau, Bahnhof
8594089 000889 NFB 8        2 000889 NFO 4        2 001  Nidau, Bahnhof
8594089 000889 NFO 4        1 000889 NFB 8        1 001  Nidau, Bahnhof
8594089 000889 NFO 4        1 000889 NFB 8        2 001  Nidau, Bahnhof
8594089 000889 NFO 4        2 000889 NFB 8        2 001  Nidau, Bahnhof

“UMSTEIGZ”:

  • In this case, the interchange time between individual journeys is specified.
8507492 30267 000011 00163 000035 000  Interlaken Ost
8507492 30267 000011 00263 000035 000  Interlaken Ost
8507492 30967 000011 00163 000035 000  Interlaken Ost
8507492 30967 000011 00263 000035 000  Interlaken Ost
8507493 00989 000011 00989 007000 000  Interlaken West
8507493 00991 000011 00991 007000 000  Interlaken West
8507493 09225 000011 09225 007000 000  Interlaken West

Additional information about service points

As mentioned above, they are contained in the “ATTRIB_XX” files.

Metastations

Initial information about metastations is available here.

In HRDF the structure is as follows (“METABHF”).

First come the transit Connections:

8581009 8530509 005
*A Y
8576101 8503665 008
*A Y
8576101 8503107 002
*A Y
8592882 8592910 005
*A Y
8592882 8592883 004
*A Y
8592882 8587061 003
*A Y
8579885 8509412 003
*A Y
8589558 8506300 002
*A Y
8500994 8592447 001
*A Y
8500994 8500897 005

Transit connections:

  • First stop
  • Second stop
  • Duration of transit
  • (optional) “S” as the separator for the seconds marker for walking time
  • (optional) seconds marker for walking time

The “*A” lines stand for an attribute:

  • It corresponds to the attribute codes from the “ATTRIBUT_XX” files (“XX” represents the language).
  • Specifically in the above case, the “Y” stands for “on foot”.

The actual information is then found in the stop group section:

8530808:  8501698  8530240  8530688  8530808
8530809:  8530809  8574311
8530818:  8508313  8530818  8572916
8530819:  8530401  8530819
8530821:  8504127  8530821
8530823:  8501553  8530823
8530824:  8501953  8530824
8530830:  8530830  8581487
8530834:  8506125  8530834  8581706
8530835:  8506122  8530835
8530841:  8509452  8530493  8530494  8530841
8530853:  8505658  8530853
8570000:  8501030  8501227  8570000
8570024:  8501159  8570024
8570034:  8501033  8501320  8570034  8583501
8570063:  8501169  8570063
8570080:  8501094  8570080
8570084:  8501037  8501228  8570084
8570109:  8530003  8570109
8570111:  8501098  8570111
8570119:  8501096  8570119
  • Code for the collective term (stop code)
  • “:”
  • List of other stops

Through-services

A through-service means that two independent journeys are combined to ultimately form a continuous journey. This is the case, for instance, for a train which actually changes train number, but still continue its journey. This also means, in most cases, that passengers can remain in their seats.

Through-services are contained in the “DURCHBI” file.

00001 000037 8500063 00002 000037 000000 8500063    % Oberwil BL
00001 000716 8574974 00002 000716 000000 8574974    % Samedan, Bahnhof
00001 000727 8594891 00002 000727 000000 8594891    % Kreuzlingen, Besmer
00001 000740 8574848 00002 000740 000000 8574848    % Davos Dorf, Bahnhof
00001 000766 8594408 00002 000766 000000 8594408    % Chur, Bondastrasse
00001 000793 8588076 00002 000793 003679 8588076    % Egerkingen, G?u Park
00001 000799 8578507 00002 000799 000000 8578507    % Herisau, Bahnhof
00001 000811 8589405 00002 000811 000000 8589405    % F?llinsdorf, Giebenacherstr.
00001 000812 8589224 00002 000812 000000 8589224    % Waldibr?cke, Bahnhof
00001 000817 8578987 00002 000817 000000 8578987    % Brione s. Minusio, Chiesa
00001 000819 8502998 00002 000819 955858 8502998    % Sursee, Bahnhof
00001 000839 8502988 00002 000839 000000 8502988    % Walchwil, Bahnhof
00001 000840 8590159 00002 000840 000000 8590159    % Aarau, W?schnauring
00001 000858 8594259 00002 000858 000000 8594259    % Canobbio, Paese
00001 000862 8578837 00002 000862 000000 8578837    % Olivone, Petullo
00001 000879 8578259 00002 000879 000000 8578259    % Sissach, Bahnhof
00001 000881 8587086 00002 000881 000000 8587086    % Puplinge, mairie
00001 000883 8587848 00002 000883 000000 8587848    % Luterbach, Bahnhof Nordseite
00001 000889 8592462 00003 000889 000000 8592462    % Biel/Bienne, Fuchsenried
00001 000896 8573945 00002 000896 000590 8573945    % Gossau SG, Bahnhof
00001 000955 8591803 00002 000955 000000 8591803    % Ruvigliana, Paese
00001 007051 8576671 24064 000871 000000 8576671    % 
00002 000766 8594412 00307 000766 000000 8594412    % Chur West, Bahnhof
00002 000807 8573570 00084 000807 000000 8573570    % 
00002 000823 8500899 09185 000823 007494 8500899    % Basel Messeplatz
00003 000011 8500010 30003 000011 014592 8500010    % 
00003 000716 8574949 00004 000716 000000 8574949    % St. Moritz Bad, Signal

The structure comprises:

  • First journey: Journey number, administration (which means business organisation), last stop’s code
  • Second journey: Journey number, administration
  • Day of operation field number (see Calendar)
  • (optional) first stop of the 2nd journey
  • (optional) attribute highlighting through-service
  • Comments (mostly the relevant railway station)

In the case of cross-border trains, only the Switzerland part is contained in the HRDF. However, no through-service is indicated in this case, even though there is one.

Extensions for HRDF deliveries from autumn 2017

The following extensions are planned for autumn 2017:

  • Different names for the same train stop in the “station” file
  • Integration of border Points

Different names for the same train stop in the “station” file

It sometimes happens that the name of a train stop is changed. Currently, the name that is valid on the export day is always transmitted. With the new extension the name will be communicated as follows:

  • For the present timetable period, the current name will continue to be transmitted.
  • For the upcoming timetable period, the name will be transmitted that is valid on the timetable period’s first day of validity.

Integration of border points

Border points are communicated in a new way. They may represent national borders or other types of borders. Border points can be represented by either real or virtual train stops. The virtual border points are also transmitted in the GRENZHLT file.

Changes active as of July 2021

Export HRDF 5.40

Scope of export

SLOID (Swiss Location ID) of the tracks / stop edges provided.

The file with the properties of the stops is made available twice. Only one file can be used at a time:

 

The file with the use of the track information is made available three times. Only one file can be used at a time:

  • The content and scope of the GLEIS file remains unchanged.
    File GLEIS_LV5 now contains the SLOID of the tracks / retaining edges, if available.
  • The coordinates are defined according to the regulations of LV_95
    File GLEIS_WGS now contains the SLOID of the tracks / retaining edges, if available.
  • The coordinates are defined according to the regulations of WGS84

 

Example scope of an export 5.40.41:

File type BHFART_60.

In this file type, the SLOID of the stops and tracks / stop edges are transmitted. Example:

File type GLEIS_LV95

In this file type, the SLOID and coordinates, if available, are transmitted according to LV95 of the tracks / stop edges.

Example:

File type GLEIS_WGS

In this file type, the SLOID and coordinates, if available, according to WGS84 of the tracks / stop edges are transmitted.

example

hh

More detailed information