Error error loading GTFS file

71 views
Skip to first unread message

Александр

unread,
Sep 4, 2024, 8:48:37 PM9/4/24
to AequilibraE
Hello everyone!

When uploading an GTFS file to the project, the following error pops up:
"KeyError: 11
Traceback (most recent call last):
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\modules\public_transport_procedures\gtfs_importer.py", line 94, in execute_importer
    feed.doWork()
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 207, in doWork
    self.execute_import()
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 214, in execute_import
    self.load_date(self.__target_date__)
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 202, in load_date
    self.__build_data()
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 305, in __build_data
    self.builds_link_graphs_with_broken_stops()
  File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 451, in builds_link_graphs_with_broken_stops
    route_types = [mode_id for mode_id in route_types if mode_correspondence[mode_id] not in self.graphs]
                                                        ~~~~~~~~~~~~~~~~~~~^^^^^^^^^
KeyError: 11
"


In the dictionary "mode_corresponence" all lines are commented out, routes.txt I double-checked - where else could there be a problem or how can I try to solve it?

Pedro Camargo

unread,
Sep 5, 2024, 4:21:00 AM9/5/24
to AequilibraE
Hi Sanek,

This is the kind of thing that is much easier to solve directly in Python, as debugging code inside QGIS is a royal pain in the neck.

What transit modes do you have in your GTFS feed?

Cheers,
Pedro



---- On Thu, 05 Sep 2024 10:47:36 +1000 Александр <alem...@gmail.com> wrote ---

--
You received this message because you are subscribed to the Google Groups "AequilibraE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aequilibrae...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/aequilibrae/21605e41-c982-4e13-8491-3d6ed07eb6d1n%40googlegroups.com.

Александр

unread,
Sep 5, 2024, 4:27:36 AM9/5/24
to AequilibraE
Hi Pedro,

route_type

3

1

11

2


четверг, 5 сентября 2024 г. в 10:21:00 UTC+2, Pedro Camargo:

Pedro Camargo

unread,
Sep 5, 2024, 4:28:54 AM9/5/24
to Aequi...@googlegroups.com
My gut feel is that it is trying to Map-match modes other than bus, but hard to know. 

Cheers, 
Pedro 




---- On Thu, 05 Sep 2024 18:26:40 +1000 alem...@gmail.com wrote ----

Aleksandr Khilko

unread,
Sep 5, 2024, 10:42:06 AM9/5/24
to AequilibraE
Yes, I tried to add the missing mods in line 129 to the route_type list in notepad lib_gtfs.py:

    def map_match(self, route_types=[3, 1, 2, 11]) -> None:  # noqa: B006

 ,  but the error is similar.

Perhaps there are some other ideas?

P.S. Python: 3.12.4
Aequilibra 1.0.3
четверг, 5 сентября 2024 г. в 10:28:54 UTC+2, Pedro Camargo:

Jamie Cook

unread,
Sep 5, 2024, 6:54:47 PM9/5/24
to Pedro Camargo, Aequi...@googlegroups.com
Hi Sanek, 

I'm not 100% sure why those modes were commented out but my guess is that it was a decision that they didn't have a direct correspondence to a supported road type... route_type 11 is a catenary electric bus/tram - so I guess it could be routed using the road network in the same way as route_type 3. Could you test it out by making an adjustment as per this image:
image.png
1: Subway and 2: Rail routes should not be map matched to your road network.

Route types

Valid options are:

  • 0 - Tram, Streetcar, Light rail. Any light rail or street level system within a metropolitan area.

  • 1 - Subway, Metro. Any underground rail system within a metropolitan area.

  • 2 - Rail. Used for intercity or long-distance travel.

  • 3 - Bus. Used for short- and long-distance bus routes.

  • 4 - Ferry. Used for short- and long-distance boat service.

  • 5 - Cable tram. Used for street-level rail cars where the cable runs beneath the vehicle, e.g., cable car in San Francisco.

  • 6 - Aerial lift, suspended cable car (e.g., gondola lift, aerial tramway). Cable transport where cabins, cars, gondolas or open chairs are suspended by means of one or more cables.

  • 7 - Funicular. Any rail system designed for steep inclines.

  • 11 - Trolleybus. Electric buses that draw power from overhead wires using poles.

  • 12 - Monorail. Railway in which the track consists of a single rail or a beam.



Jamie Cook

unread,
Sep 5, 2024, 7:51:26 PM9/5/24
to Pedro Camargo, Aequi...@googlegroups.com

Aleksandr Khilko

unread,
Sep 5, 2024, 7:59:00 PM9/5/24
to AequilibraE
Hi Jamie

I tried to bring mode_corresponence in line with your comment - the error is the same. I tried it in the file routes.txt replace route_type=11 with 3, now the code is looking for a subway:

2024-09-06T01:45:46     WARNING    Traceback (most recent call last):


              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\modules\public_transport_procedures\gtfs_importer.py", line 94, in execute_importer
              feed.doWork()
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 207, in doWork
              self.execute_import()
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 214, in execute_import
              self.load_date(self.__target_date__)
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 202, in load_date
              self.__build_data()
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 305, in __build_data
              self.builds_link_graphs_with_broken_stops()

              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\lib_gtfs.py", line 457, in builds_link_graphs_with_broken_stops
              graph = mm.build_graph_with_broken_stops(mode_id)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\transit\map_matching_graph.py", line 74, in build_graph_with_broken_stops
              modename = self.geotool.network.modes.get(self.__mode).mode_name
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
              File "C:\Users/Sanek/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\qaequilibrae\packages\aequilibrae\project\network\modes.py", line 99, in get
              raise ValueError(f"Mode {mode_id} does not exist in the model")
             ValueError: Mode Subway does not exist in the model

             


пятница, 6 сентября 2024 г. в 01:51:26 UTC+2, Jamie Cook:

Jamie Cook

unread,
Sep 5, 2024, 8:04:55 PM9/5/24
to Aleksandr Khilko, AequilibraE
replacing 11 with 3 in the gtfs file is also a way to achieve the same thing... I think you'll find that the problem is now with the route_type 1 and 2 which I said you shouldn't be trying to mapmatch.

when you call the map match function, just do 

# Now we execute the map matching to find the real paths.
# Depending on the GTFS size, this process can be really time-consuming.
transit.set_allow_map_match(True)
transit.map_match([3,11])


Aleksandr Khilko

unread,
Sep 5, 2024, 9:21:24 PM9/5/24
to AequilibraE
Do I understand correctly that the map match function when loading GTFS via GUI in QGIS is called by lib_gtfs.py and do I need to make this edit in it?

Снимок экрана 2024-09-06 030910.png
I tried to start downloading my original GTFS file in this form, but the error returned:
Снимок экрана 2024-09-06 030823.png

пятница, 6 сентября 2024 г. в 02:04:55 UTC+2, Jamie Cook:

Jamie Cook

unread,
Sep 6, 2024, 4:14:52 AM9/6/24
to Aleksandr Khilko, AequilibraE
It seems that the version you have installed is a little behind the version on github at the moment. This might just be something that is fixed in the head version but needs a little bit of time to make it into the QAequilibrae packaged version.

Can you confirm that you get this error when you are just mapmatching route_type = 3 (and yes you probably will have to edit that file to effect that change).

Pedro Camargo

unread,
Sep 6, 2024, 4:17:41 AM9/6/24
to AequilibraE
Aleksandr,

We are currently looking for funding to update the AequilibraE plugin with the latest changes and capabilities available in Python, but it may take some time to find the funding and execute the changes, which are quite extensive.

Cheers,
Pedro


---- On Fri, 06 Sep 2024 18:14:32 +1000 Jamie Cook <jimi...@gmail.com> wrote ---

It seems that the version you have installed is a little behind the version on github at the moment. This might just be something that is fixed in the head version but needs a little bit of time to make it into the QAequilibrae packaged version.

Can you confirm that you get this error when you are just mapmatching route_type = 3 (and yes you probably will have to edit that file to effect that change).

On Fri, 6 Sept 2024 at 11:21, Aleksandr Khilko <alem...@gmail.com> wrote:


--
You received this message because you are subscribed to the Google Groups "AequilibraE" group.
To unsubscribe from this group and stop receiving emails from it, send an email to aequilibrae...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages