This vignette outlines how to produce GTFS timetables for the heavy rail network using ATOC CIF files.

Getting Data

Data for train timetables can be downloaded from ATOC you will need to register for a free account and log in.

\label{fig:atoc_download}Download ATOC data

Download ATOC data

You will get a zipped folder with a name like ttis123.zip.

Converting ATOC Data to GTFS

To do a simple conversion to GTFS, load the package, and use the atoc2gtfs function. The function requires the following arguments.

  • path_in is the file path to the ATOC timetable file, this comes a zipped folder with a name like ttis627.zip
  • ncores If > 1 then multicore processing is used to speed up the processing. Always leave one spare core for your OS.

A simple example is shown below:

library(UK2GTFS)
path_in <- "ttis627.zip"
gtfs <- atoc2gtfs(path_in = path_in,
          ncores = 3)

Once the conversion has been completed, you can save the GTFS file.

gtfs_write(gtfs, 
           folder = "C:/GTFS",
           name = "gtfs_ttis627")

This will save the GTFS file to C:/GTFS/gtfs_ttis627.zip

Alternative Data Sources

CIF Files are available from Network Rail, the formatting is slightly different and so a separate function nr2gtfs() is provided.

Advanced features

The atoc2gtfs() function gives some customization options to how the GTFS file is built. It is also just a wrapper around other functions in the package. This section will explain the main steps.

Importing ATOC Data

After unzipping the folder, the reading of the ATOC data is done with the following functions:

Other files are currently ignored.

TIPLOC Locations

The timetable data refers to locations such as stations, junctions, etc using a TIPLOC id. The locations of these are stored in the .msn file, but are not always accurate. Therefore the package comes with a tiplocs object which includes improved location data for TIPLOCS.

IF you wanted to build using the locations included in the ATOC data, then you can use locations = "file" in atoc2gtfs() or manually build the stops using station2stops().

Agency

The data required to create the GTFS agency.txt file is not present in the ATOC CIF files. Therefore the package contains an example file instead.