UK2GTFS R Package Support

125 views
Skip to first unread message

Rosie Plimmer

unread,
Sep 10, 2025, 4:31:57 AMSep 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 AMSep 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 AMSep 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

Ian Sargent

unread,
Sep 23, 2025, 10:10:49 AMSep 23
to A gathering place for the Open Rail Data community
Just to note that the FLF file is effectively redundant these days and only supplied for those legacy journey planners that are unable to use the ALF file. If you make use of ALF then you can ignore the FLF.

For history buffs: the FLF file dates back to the very first British Rail journey planner (CATE) circa 1992. The ALF format was developed later for National Rail Enquiries, and subsequently made available to all other journey planners.

Michael Tsang

unread,
Sep 29, 2025, 12:27:27 PMSep 29
to openrail...@googlegroups.com
Hi Rosie,

I am using dtd2mysql to convert the ATOC CIF format to GTFS. Specifically, I
work in Aubin MaaS and has made a fork which is actively developed to include
the latest features in the GTFS standard and local knowledge as appropriate,
and is good enough for the use in a production-level journey planner.

Thanks,
Michael

On Wednesday, 10 September 2025 09:28:42 British Summer Time Rosie Plimmer
wrote:
> 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
> <https://github.com/itsleeds/UK2GTFS> 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: Image]
> <https://private-user-images.githubusercontent.com/72813264/487344054-7108d6
> 3d-d92e-4073-8888-00908189483a.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
> eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtl
> eSI6ImtleTUiLCJleHAiOjE3NTc0OTI3MjgsIm5iZiI6MTc1NzQ5MjQyOCwicGF0aCI6Ii83Mjgx
> MzI2NC80ODczNDQwNTQtNzEwOGQ2M2QtZDkyZS00MDczLTg4ODgtMDA5MDgxODk0ODNhLnBuZz9Y
> LUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09E
> WUxTQTUzUFFLNFpBJTJGMjAyNTA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZY
> LUFtei1EYXRlPTIwMjUwOTEwVDA4MjAyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0
> dXJlPWQ4YzcxMTg5N2EyMDI5MDRmZjdjZjZjNmY1MjE2ZmQyODY2ZTA2YjUyNDNlMzNhZGVjYmUy
> NGQzZDg5M2ZjMmImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.QNX_IoQ96kyu5MiU21NCkYcR
> TFN8zEw61e2xSGqtgME>
>
> The format of the alf file looks better, but is unused in atoc2gts():
> [image: Image]
> <https://private-user-images.githubusercontent.com/72813264/487351294-c9fd80
> 25-e742-42f9-9bd5-2c8a761288a3.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.
> eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtl
> eSI6ImtleTUiLCJleHAiOjE3NTc0OTI3MjgsIm5iZiI6MTc1NzQ5MjQyOCwicGF0aCI6Ii83Mjgx
> MzI2NC80ODczNTEyOTQtYzlmZDgwMjUtZTc0Mi00MmY5LTliZDUtMmM4YTc2MTI4OGEzLnBuZz9Y
> LUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09E
> WUxTQTUzUFFLNFpBJTJGMjAyNTA5MTAlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZY
> LUFtei1EYXRlPTIwMjUwOTEwVDA4MjAyOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0
> dXJlPTM1MjdiZmNkMjBhYTc1MTdhZWZlZjkzMGI0NGVmNjMzN2JkNzE1ZDIxZTk5NTdiYjNjZWQz
> OTM3ZjUyODdmYjgmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.V5F2w5oXp_oRSayoO1389GVd
> b_JVJeHlRMFdmpPfCyA>
>
> 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,Y396
> 97 2025-09-09 16:11:45.493225 Constructing calendar and calendar_dates Error
signature.asc
Reply all
Reply to author
Forward
0 new messages