I use some GRASS tools in QGIS Python Console. All tools I use return a dictionary with a key and a value which contains string path, like this: {"output": "file/path"}. There is an answer here. It suggests to use that string in QgsVectorLayer. But writing/reading a file to/from disk is time consuming.

I tried processing.runAndLoadResults and processing.run. Both add a layer. But before adding the layer, they save the layer to disk, then add it.

processing.run("grass7:v.buffer", {..., 'output':'TEMPORARY_OUTPUT', ...})
# returns {'output': '/tmp/.../output.gpkg'} -> file path

processing.runAndLoadResults("grass7:v.buffer", , {..., 'output':'TEMPORARY_OUTPUT', ...})
# returns {'output': '/tmp/.../output.gpkg'} -> file path

I wonder, is there a way to get the returned/added layer by the GRASS tool without saving to disk (to use in the next processing tool in a Python script)?

1 Answer 1


I don't think there is a way when using a GRASS tool in QGIS. I noted that GRASS tools I used always returned file path. The only way I could achieve to get layer without saving it was to use QGIS native processing tools via processing.run method. This answer explains how to do.

If you use the output layer as intermediate layer, I recommend you to use equivalent native(QGIS) tool (if exists) via processing.run which returns QgsVectorLayer instance without saving it to disk. Otherwise, I suggest you to run a tool using processing.run and then use QgsVectorLayer to add the output to memory.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.