Saving processing results in a file using QGIS modeler?

If you want to pass a path in your model to save your shapefiles into instead of doing it manually, a custom script is probably the way to go. You can write a script to run the Extract by location tool and define the path of the output. Something like this perhaps:

##Extract_by_location=name
##Layer=vector
##Additional_layer=vector

layer = processing.getObject(Layer)
output_path = "C:/Users/You/Desktop/" + layer.name() + ".shp"

processing.runalg("qgis:extractbylocation", Layer, Additional_layer, u'contains', 0.00, output_path)

Replace the Extract by location tools in your model with this script and it will save the results to a shapefile in the path you specified.


QGIS modeler treats any tool as intermediate which does not save any output, unless otherwise stated.

To force the model to export a result, you have to input a layer output name in the Tool row.

enter image description here

If I want to export the above result as a layer, I input a value in the output as so: enter image description here

What this does is add a dialoge box whenyou run the tool that you can set the output file:

enter image description here

The model itself shows the types of data with colors: purple for inputs, cyan for outputs