On 23 April 2018 at 19:59, matteo <[email protected]> wrote: > Hi devs, > > sorry if I missed something on this topic, but it seems that it is not > possible using memory layer when running algorithms from the console. > > A simple example should explain everything: > > # QGIS > parameters = { > 'INPUT' : 'big', > 'OVERLAY': 'small', > 'OUTPUT':'memory:' > } > > result = processing.run("qgis:difference", parameters) > QgsProject.instance().addMapLayer(result['OUTPUT']) > > # SAGA > > parameters_saga = { > 'A': 'big', > 'B': 'small', > 'SPLIT': True, > 'RESULT': 'memory:' > } > > result_saga = processing.run("saga:difference", parameters_saga) > > # nothing is added with this code > QgsProject.instance().addMapLayer(result_saga['RESULT']) > > > with the code of above I noticed that the big difference is in: > > # QGIS > result['OUTPUT'] > <qgis._core.QgsVectorLayer object at 0x7f92a8a479d8 > > and > > #SAGA > result_saga['RESULT'] > 'memory:' > > > the same happens with GRASS. The algorithms work fine if the result is > saved as file > > Am I missing something for SAGA and GRASS?
No - neither SAGA nor GRASS have any concept of QGIS memory layers. You need to give them a disk-based file path to save their outputs to. If you use a memory layer as an input to these algs it will also have to save it out to a disk based format, but this is done automatically by saving to a file in the temp folder. We could potentially do the same thing to allow SAGA/GRASS algs to output to a memory layer by first saving the output to a shp in the temp folder, then loading that file and copying the features to a memory layer. But it would be rather inefficient and counter productive - you're still being forced to loop over the disk-based format, so you're just adding extra processing for little gain. Nyall _______________________________________________ QGIS-Developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
