This question is a follow up from a suggestion from this thread:

How to export a single feature (line) from multiple layers and export to individual layers?

I'm creating a batch process that selects a line (feature) from a vector layer and saves the selected feature to a child layer containing the name of the parent.

I'm using $length = maximum($length, group_by:= "id") as the expression because I want to select the longest line in each layer.

The question is how do I export only selected features in the Processing Modeler? I can't find a "Export - Save Selected Features As..." option.

enter image description here

enter image description here

  • Could extract by expression help you? Can't test right now.
    – Erik
    Jan 18, 2019 at 13:36
  • I'm already using that: $length = maximum($length, group_by:= "id")
    – Steffan
    Jan 18, 2019 at 13:39
  • What happens when you save the generated output? Also, you use "select" instead of "extract"
    – Erik
    Jan 18, 2019 at 13:42
  • 1
    As far as I know, extract by expression should work as it's a tool that works exactly like select by expression but has the ability to write a file as output. If the processing model is more complex and this wouldn't work, can you show the workflow?
    – Gabriel
    Jan 18, 2019 at 13:53
  • 1
    @AndreSilva, thank you for your work. I can't know how Steffan solved his issue, but I propose the solution of extracting the features, naming the output and saving it when running the model. Mar 6, 2019 at 0:07

1 Answer 1


To export features from expression in the modeler, first you need to Extract features by expression instead of select them.

In the modeler algorithm, you can define a named output.

Output generated by an algorithm are handled a bit differently when the algorithm is used as a part of a model. Instead of selecting the filepath where you want to save each output, you just have to specify if that ouput is an intermediate layer (and you do not want it to be preserved after the model has been executed), or it is a final one.

When layers are not a final result, you should just leave the corresponding field. Otherwise, you have to enter a name that will be used to identify the layer in the parameters dialog that will be shown when you run the model later.

Source: https://docs.qgis.org/testing/en/docs/training_manual/processing/modeler_twi.html#starting-with-the-graphical-modeler

When you run the model, you can define to write the named output to a file (instead a temporary file) and load it to the canvas or not.


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.