UK2GTFS R Package Support

61 views
Skip to first unread message

Rosie Plimmer

unread,
Sep 10, 2025, 4:31:57 AM (12 days ago) Sep 10
to A gathering place for the Open Rail Data community
Hi all,

I have raised this as a Git Issue, but the repo seems inactive so I was wondering if is any expertise using itsleeds/UK2GTFS: Convert UK transport data (TransXchange / ATOC CIF) to GTFS format in R in here.

I've been trying to convert the National Rail Data CIF files from https://opendata.nationalrail.co.uk/api/staticfeeds/3.0/timetable to GTFS using the atoc2gtfs package. 

After converting the filenames to lowercase and calling atoc2gtfs I cannot get it to work.

With transfers=TRUE the error is:
Error in names(table) <- c("Type", "del1", "Mode", "del2", "from", "del3", :
'names' attribute [10] must be the same length as the vector [4]

I think this comes from the format of the flf file. The flf file downloaded is in a verbose format, that does not match the expected format for importFLF():
Image

The format of the alf file looks better, but is unused in atoc2gts():
Image

Has something changed with the way National Rail provide the CIF data?

I am also having issues with the function if transfers=FALSE. The error produced here is:
2025-09-09 16:11:45.053712 Some calendar dates had incorrect start or end dates that did not align with operating day bitmask.
Services=Y09651,Y09826,G33437,Y00652,L36706,L36756,L36896,L36952,Y39679,Y39697
2025-09-09 16:11:45.493225 Constructing calendar and calendar_dates
Error in (function (.x, .f, ..., .progress = FALSE) :
ℹ In index: 3884.
Caused by error in set():
! Supplied 19 items to be assigned to 18 items of column 'start_date'.

I'm not sure why this is happening but I think it comes from there something being wrong with the “bitmask → dates” logic in atoc_overlay()? I can't see anywhere that this function guarantees the two vectors it tries to assign (start_date vs. number of target rows) have identical length.

I've downloaded the data from Network Rail, and used nr2gtfs(), which works with no issues. Ideally, I'd have wanted the transfers data, which is why I'm keen to get clarification on the above. Although I am aware there is a way to create the transfers data manually, which I'll look into further.


I'm very much an amateur with GTFS data and might be missing something or doing something wrong! Any advice/guidance would be greatly appreciated.


Rosie Plimmer

unread,
Sep 10, 2025, 5:05:00 AM (12 days ago) Sep 10
to A gathering place for the Open Rail Data community
Apologies, just realised my images havent loaded correctly. 
Image 1 of FLF file format:
flf file format.png

Image 2 of ALF file format:
alf file format.png

Owen O'Neill

unread,
Sep 11, 2025, 7:50:04 AM (11 days ago) Sep 11
to A gathering place for the Open Rail Data community
Hi Rosie,
It's been a while since I did a load of work on that package (I ended up creating my own fork) https://github.com/oweno-tfwm/UK2GTFS

if my hazy memory is correct then the atoc CIF format is ever so slightly different to the network rail CIF format in a couple of the 'ancillary' files, so the network rail version of the conversion functions is probably the one you want (and more recently maintained) - could be it needs a bit of extra development work.

" Some calendar dates had incorrect start or end dates that did not align with operating day bitmask"
is just a warning, the data doesn't fully match the specification but it should all still work fine.

cheers
Owen
Reply all
Reply to author
Forward
0 new messages