Ignoring errors and keyerror:'distance'

I’m currently working on a university project with docker desktop, a local openrouteservice installation and QGIS and ORS Tools.

I want to analyze around 30000 operational trips of emergency medical service providers in a certain region over a year.

I got the trip information with the latitude and longitude of the start point and end point of each trip in an csv file that i load as a layer into QGIS.

Via ORS TOOLS and the function batch job-> directions-> Points (2 Layer) i want to get the driving distance and the duration of each trip.

I’m using the setting “Row-by-Row” so that the first row of layer 1 (starting point 1) is assigned to the first row of layer two (end point 1), etc.
(I made different layers with the starting points and end points with different amount of trips, so i don’t calculate the entire 30000 trips in one iteration)

When I tried to run several of it, I encounter this error message

2022-01-01T12:03:18 CRITICAL Traceback (most recent call last):
File “C:\Users/…/AppData/Roaming/QGIS/QGIS3\profiles…/python/plugins\ORStools\proc\directions_points_layers_proc.py”, line 198, in processAlgorithm
sink.addFeature(directions_core.get_output_feature_directions(
File “C:\Users/…/AppData/Roaming/QGIS/QGIS3\profiles…/python/plugins\ORStools\common\directions_core.py”, line 146, in get_output_feature_directions
distance = response_mini[‘properties’][‘summary’][‘distance’]
KeyError: ‘distance’

What does this error mean?

To me i looks like, that some coordinates of some trips may be broken.

I worked for some iteration but i can figure out which start and end point combination are broken.

Is there anyway to configure the setup to skip broken end start point combination?

Hey,

it’s rather hard to debug this without having more detailed info about the exact request you’re issuing.
Since you’re requesting around 30k routes, it’s indeed rather likely that this stems from some broken coordinates, or some other issue with one of your requests.

There is currently no way to skip things as you suggest, as the usability of that would be very hard to get right.

However, every single request that is issued by the plugin can be viewed in the ORS Tools Tab of the Log Messages Panel, available via View → Panels → Log Messages.
Maybe this can give you some insight into what is going wrong here?

If not, you’d have to provide the data you’re using, so we can try to debug this.

Best regards

1 Like