UnboundLocalError: local variable 'response' referenced before assignment

Hi,

Any ideas? I just attempted to use the ORS Tools in QGIS and received the following error:

Traceback (most recent call last):
File “/Users/xxx/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ORStools/proc/matrix_proc.py”, line 275, in processAlgorithm
duration = response[‘durations’][s][d]
UnboundLocalError: local variable ‘response’ referenced before assignment

Execution failed after 1.81 seconds

Here is the log from the failed execution:

QGIS version: 3.12.2-București

QGIS code revision: 8a1fb33634

Qt version: 5.12.3

GDAL version: 2.4.1

GEOS version: 3.7.2-CAPI-1.11.2 b55d2125

PROJ version: Rel. 5.2.0, September 15th, 2018

Processing algorithm…

Algorithm ‘Matrix From Layers’ starting…

Input parameters:

{ ‘INPUT_END_FIELD’ : ‘Locality’, ‘INPUT_END_LAYER’ : ‘/Users/xxxr/Desktop/test/All ZM reports/all zm lakes.shp’, ‘INPUT_PROFILE’ : 0, ‘INPUT_PROVIDER’ : 0, ‘INPUT_START_FIELD’ : ‘Locality’, ‘INPUT_START_LAYER’ : ‘/Users/xxx/Desktop/test/All ZM reports/all zm lakes.shp’, ‘OUTPUT’ : ‘/Users/xxx/Desktop/test/distances/points.shp’ }

Traceback (most recent call last):
File “/Users/xxx/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ORStools/proc/matrix_proc.py”, line 223, in processAlgorithm
features_points = [xformer.transform(feat.geometry().asPoint()) for feat in features]
File “/Users/xxx/Library/Application Support/QGIS/QGIS3/profiles/default/python/plugins/ORStools/proc/matrix_proc.py”, line 223, in
features_points = [xformer.transform(feat.geometry().asPoint()) for feat in features]
ValueError: Null geometry cannot be converted to a point.

Execution failed after 0.07 seconds

Loading resulting layers

Algorithm ‘Matrix From Layers’ finished

Looking at the error it seems that the plugin sees that there is missing geometry in the point layer. Can you try it with a different point file and see if that works as that will help work out if it is a data problem?

Hi,
I tried it with a totally separate point file that I created today. It’s experiencing exactly the same error.

Seems like you’re having invalid geometries in your shapefile… Try a „Repair geometries“ from the Toolbox.

I must be pretty slow. I repaired the geometries, converted them back to points from multipoints, then reran the matrix tool. Still doesn’t work.

Due to the size of the logfile, I had to upload it to google drive. Here’s a link to it, as well as the point shapefile.

The log file appears to be returning html for a web page, very weird.

log file and point shape file

Update: I removed the first part of the logfile and saved it as an html file and it is returning a web page.

What’s the URL you’re using? Just paste the full log message in the ORS Tools GUI, incl URL and parameters.

The ORS Tools GUI doesn’t have a matrix option, I’m running it from the processing toolbox.

Ok,
I managed to pull the ORS Tools log for QGIS, this is what it has.

2020-07-09T17:54:40 INFO url: https://openrouteservice.org/v2/matrix/driving-car?
Parameters: {
“locations”: [
[
-96.025163,
34.5230681
],
[
-95.2305163,
35.8695429
],
[
-94.8629035,
36.6127128
],
[
-96.4217833,
36.4046696
],
[
-96.8746995,
36.6959538
],
[
-96.3597233,
36.1896598
],
[
-97.2282406,
36.1359391
],
[
-95.1863523,
36.2334268
],
[
-97.1853084,
36.1819293
],
[
-97.0756894,
34.0718198
],
[
-97.0130867,
36.7215136
],
[
-96.9317925,
33.9549729
],
[
-95.5943085,
36.5510702
],
[
-94.7768917,
35.3467619
],
[
-96.1781435,
36.3695025
],
[
-97.4357041,
35.3525205
],
[
-95.1685723,
35.55343
]
],
“sources”: [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
],
“destinations”: [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16
],
“metrics”: [
“duration”,
“distance”
],
“id”: “Matrix”
}
2020-07-09T17:54:42 CRITICAL Feature ID Matrix caused a ApiError: 404 (

Yeah, wrong URL. You’re missing the “api.” after “https”.

Thanks, that fixed not only this problem but a host of others as well.

:slightly_smiling_face: