Yes, that is the method I am looking for. Thank you, Etienne.
I am still curious why the output is different depending on the
isChildAlgorithm parameter??
Simon
Am 24.11.2021 um 12:50 schrieb Etienne Trimaille:
This might help you ?
QgsProcessingUtils::mapLayerFromString()
https://qgis.org/api/classQgsProcessingUtils.html#aa1c2360e52d2ed8100faf02a35125b17
Le mer. 24 nov. 2021 à 11:19, Simon Gröchenig
<simon.groeche...@salzburgresearch.at> a écrit :
Hi developers,
I am developing a Python processing algorithm with some child
algorithms. I am struggling to find a way to access a child
algorithm's output vector layer. I want to use
isChildAlgorithm=True in order to correctly set the feedback progress.
* If I use processing.run(...) with setting the parameter
isChildAlgorithm to False (= default), the vector layer (via sink)
is returned as a QgsVectorLayer.
* If I set isChildAlgorithm to True, only the dest_id is returned
as a string. I did not find a solution on how I retrieve the
corresponding QgsVectorLayer.
* Is it intentional that the vector layer is returned as
QgsVectorLayer or str (dest_id), depending on the isChildAlgorithm
parameter?
* How can I access output QgsVectorLayer from a child algorithm?
This is a minimum example where you can modify the
is_child_algorithm parameter:
parameters = {
'INPUT': QgsVectorLayer('Point?crs=epsg:31258', 'locations',
"memory"),
'DISTANCE': 10,
'OUTPUT': 'TEMPORARY_OUTPUT'
}
result = processing.run("native:buffer", parameters,
is_child_algorithm=False )
vector_layer = result['OUTPUT']
print(str(type(vector_layer)))
Best regards
Simon
--
Simon Gröchenig MSc
MTA - Mobility & Transport Analytics
Salzburg Research Forschungsgesellschaft mbH
Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
T: +43.662.2288-314
simon.groeche...@salzburgresearch.at
http://www.salzburgresearch.at
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
--
Simon Gröchenig MSc
MTA - Mobility & Transport Analytics
Salzburg Research Forschungsgesellschaft mbH
Jakob-Haringer-Straße 5/3 | 5020 Salzburg, Austria
T: +43.662.2288-314
simon.groeche...@salzburgresearch.at
http://www.salzburgresearch.at
_______________________________________________
QGIS-Developer mailing list
QGIS-Developer@lists.osgeo.org
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer