<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Hi Richard,</p>
<p><br>
</p>
<p>thanks for your hint! By adding the QgsProcessingFeatureSourceDefinition, it works :) </p>
<p><br>
</p>
<p>Regards,</p>
<p>Marie</p>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>Von:</b> Richard Duivenvoorde <rdmailings@duif.net><br>
<b>Gesendet:</b> Dienstag, 13. September 2022 20:46:59<br>
<b>An:</b> Hesels, Marie-Christine; qgis-user@lists.osgeo.org<br>
<b>Betreff:</b> Re: [Qgis-user] Issues by using a script inside the python console</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">I use succesfully the following in a script and a plugin:<br>
<br>
         # Voronoing ONLY the selected<br>
         # NOTE: the colon (:) behind 'memory' in the 'OUTPUT' param is mandatory,<br>
         # else QGIS will create a geopackage!<br>
         selected = True<br>
         params = {<br>
             'INPUT': QgsProcessingFeatureSourceDefinition(point_layer.id(), selectedFeaturesOnly=selected),<br>
             'OUTPUT': 'memory:',<br>
             'BUFFER': 5,<br>
         }<br>
         result = processing.run("qgis:voronoipolygons", params)<br>
<br>
Maybe you can use that to reconstruct your call?<br>
<br>
Regards,<br>
<br>
Richard Duivenvoorde<br>
<br>
<br>
On 9/13/22 10:52, Hesels, Marie-Christine via Qgis-user wrote:<br>
> Hi all,<br>
> <br>
> <br>
> I am currently using the "Snap to Roads" script inside my qgis environment, to match gpx-points to the OSM (<a href=""></a>https://spatialthoughts.com/2020/02/22/snap-to-roads-qgis-and-osrm/ <<a href="https://spatialthoughts.com/2020/02/22/snap-to-roads-qgis-and-osrm/">https://spatialthoughts.com/2020/02/22/snap-to-roads-qgis-and-osrm/</a>>).<br>
> <br>
> I am able to execute the Script by using the QGIS Script Environment:<br>
> <br>
> <br>
> <br>
> Unfortunatly, I would like to run the script via python console inside QGiS, but this doesn't work at all ...<br>
> <br>
> <br>
> By executing the following command:<br>
> <br>
> <br>
> layer_SnappedLine = processing.run("script:snap_to_roads",<br>
> {'INPUT':layer_GPX_Points['OUTPUT'],<br>
> 'SERVICE':'http://127.0.0.1:5000',<br>
> 'TOLERANCE':10,<br>
> 'OUTPUT':'TEMPORARY_OUTPUT'})<br>
> <br>
> I receive the error message:<br>
> <br>
> "Traceback (most recent call last):<br>
> <br>
>    File "C:\PROGRA~1\QGIS32~1.10\apps\Python39\lib\code.py", line 90, in runcode<br>
>      exec(code, self.locals)<br>
>    File "<input>", line 1, in <module><br>
>    File "C:\PROGRA~1/QGIS32~1.10/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 108, in run<br>
>      return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)<br>
>    File "C:\PROGRA~1/QGIS32~1.10/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 205, in runAlgorithm<br>
>      layer = context.takeResultLayer(result)  # transfer layer ownership out of context<br>
> TypeError: QgsProcessingContext.takeResultLayer(): argument 1 has unexpected type 'QgsFeatureSink'"<br>
> <br>
> Can anybody help me with this issue? I am using QGIS Version 3.22.10<br>
> <br>
> Regards and thanks,<br>
> Marie<br>
> <br>
> <br>
> _______________________________________________<br>
> Qgis-user mailing list<br>
> Qgis-user@lists.osgeo.org<br>
> List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
> Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
<br>
</div>
</span></font>
</body>
</html>