10

I want to do a simple merge of some algorithm outputs in QGIS graphical modeler (not for an iterative process, like my previous question "Collect results of iterative processes in QGIS graphical modeler", but just for two outputs of parallel/forked extractions).

I feel like this is so basic, it should be obvious: Right where it says 'Input layers' I ought to be able to select multiple inputs, but choosing "algorithm-output" gives me only one pulldown menu.

How do I connect two outputs as input layers (as indicated in yellow)?

example in QGIS graphical modeler showing the UI

I tried using 'Expression' as Input, and there I can select output layers as variables (e.g. @outputX). However I don't know how to use this expression to use multiple variables, either (e.g. @outputX, @outputY gives an error:

Unexpected COMMA where $end was expected

other variations don't work as well, e.g. with space, semi-colon, ...).

2 Answers 2

13

Change your input back to the 123 Button (="Value-Input"). If you then click on the three dots ... to the right of the input line, you can choose your layers. Here, all layers from your current project are available as well as all algorithm outputs and model inputs.

Indeed, this is a little confusing as "merge vector layers" seems to be the only graphical modeler tool acting this way...

enter image description here

enter image description here

4
  • Correct me if I'm wrong, but imho this can only be configured within the model and not when executing it. So it will only work within a certain project/configuration or anyone who uses the model has to edit the algorithm configuration before model execution. This contradicts the paradigm of considering models as 'black boxes' with only input and output interfaces and whichs content does not matter to the user. Apr 22, 2021 at 11:56
  • 1
    I actually find this solution a bit more elegant than using the array in expression. @JochenSchwarze this works as I'd expect, not appearing as input parameters of the model but using temporal results within the model (which of course are not configured as model input). If you want to configure the input when executing the model, use not "temporal algorithm outputs" as input but create input parameters and select those.
    – Honeybear
    Apr 27, 2021 at 13:14
  • @JochenSchwarze, could you explain how adding a step that merges two outputs inside a model is against the 'black-box' paradigm? For me it still seems pretty default-values friendly. Apr 19, 2022 at 16:24
  • @JochenSchwarze no, not at all. Actually the opposite is the case: it helps keeping the model a blackbox when you want to merge several outputs from previous algorithms in the model. It only is not a good method when you have several modelinputs and each time you want to merge different ones directly without processing them in the model. But in that case why using a model at all?
    – MrXsquared
    Apr 19, 2022 at 16:32
9

I'm on QGIS 3.18.2, array() works for me. Consider this model:

enter image description here

You are on the right track with expression, in my case it looks like

enter image description here

following the hint "Expected input: an array of layer paths, ...", strange that I couldn't get this to work with string concatenation either (like ... || ';' || ...)

Your Answer

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

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