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 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.
To do a simple conversion to GTFS, load the package, and use the
transxchange2gtfs() function. The function requires the following arguments.
path_inis the file path to either a single zip folder or many XML files
ncoresIf > 1 then multicore processing is used to speed up the processing. Always leave one spare core for your OS.
try_modeif TRUE file that can’t be converted are skipped
A simple example is shown below:
Once the conversion has been completed, you can save the GTFS file.
gtfs_write(gtfs, folder = "C:/GTFS", name = "gtfs_EA")
This will save the GTFS file to
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” ).
transxchange2gtfs is unable to merge it will return a list of GTFS objects. You can then manually merge using
force = TRUE this is almost always ok.
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_replace to improve the NaPTAN.