This vignette outlines how to produce GTFS timetables for buses and light rail network using TransXchange files.

Note that GTFS data is now published for buses in Great Britain at Open Bus Data. UK2GTFS benefits from additional data checks and also including non-bus modes such as tram, underground, and boats.

TransXchange Data - for bus, tram, and metro

TransXchange data can be downloaded from Traveline you will need to apply for free access to the FTP sever to download the data.

The data comes as zipped folders for different regions of Great Britain.

Converting TransXchange to GTFS

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

  • path_in is the file path to either a single zip folder or many XML files
  • ncores If > 1 then multicore processing is used to speed up the processing. Always leave one spare core for your OS.
  • try_mode if TRUE file that can’t be converted are skipped

A simple example is shown below:

path_in <- ""
gtfs <- transxchange2gtfs(path_in = path_in,
          ncores = 3)

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

           folder = "C:/GTFS",
           name = "gtfs_EA")

This will save the GTFS file to C:/GTFS/

Merging problems

transxchange2gtfs converts each transXchange file into its own GTFS file. Then uses gtfs_merge to combine these into a single GTFS file. When this is done checks are performed to make sure the merged GTFS is valid. However this can fail. Often due to small differences between files such as the Bus operator having two spellings of their company name (e.g.
“Yorkshire Coastliner Ltd” or “Yorkshire Coastliner” ).

If transxchange2gtfs is unable to merge it will return a list of GTFS objects. You can then manually merge using gtfs_merge and force = TRUE this is almost always ok.

Stop Locations - The NaPTAN

TransXchange files do not contain the location of stops, so we must look them up in the NaPATAN. The NaPTAN is updated regularly so UK2GTFS will always download the latest copy using get_naptan(). However the NaPTAN is not perfect, it misses some stops and has incorrect locations for others. UK2GTFS uses two internal files naptan_missing and naptan_replace to improve the NaPTAN.