[Qgis-user] Issues by using a script inside the python console

Hesels, Marie-Christine marie.hesels at rwth-aachen.de
Tue Sep 13 01:52:23 PDT 2022


Hi all,


I am currently using the "Snap to Roads" script inside my qgis environment, to match gpx-points to the OSM (https://spatialthoughts.com/2020/02/22/snap-to-roads-qgis-and-osrm/).



I am able to execute the Script by using the QGIS Script Environment:

[cid:317d9d57-3f6d-41dd-8234-b68dcfa66fc2]


Unfortunatly, I would like to run the script via python console inside QGiS, but this doesn't work at all ...


By executing the following command:


layer_SnappedLine = processing.run("script:snap_to_roads",
{'INPUT':layer_GPX_Points['OUTPUT'],
'SERVICE':'http://127.0.0.1:5000',
'TOLERANCE':10,
'OUTPUT':'TEMPORARY_OUTPUT'})


I receive the error message:

"Traceback (most recent call last):

  File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "C:\PROGRA~1/QGIS32~1.10/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 108, in run
    return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)
  File "C:\PROGRA~1/QGIS32~1.10/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 205, in runAlgorithm
    layer = context.takeResultLayer(result)  # transfer layer ownership out of context
TypeError: QgsProcessingContext.takeResultLayer(): argument 1 has unexpected type 'QgsFeatureSink'"

Can anybody help me with this issue? I am using QGIS Version 3.22.10

Regards and thanks,
Marie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220913/cde6f9d0/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pastedImage.png
Type: image/png
Size: 25278 bytes
Desc: pastedImage.png
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20220913/cde6f9d0/attachment.png>


More information about the Qgis-user mailing list