2

Using QGIS 2.18.14, Windows 10, I need help with Batch Processing. I have created this simple model with just two algorithms, a reproject followed by polygon centroids:

enter image description here

When I try to run this model as a batch process, I follow the QGIS instructions for filling out the Parameter Table. The autofill dropdown for the first algorithm works correctly, allowing me to select the input layer.

However, there is a problem with the second algorithm's dropdown; just like the first algorithm it only includes the input layer as an option. It does not allow me to select the output from first algorithm, which is necessary to complete the model.

enter image description here

How do I enable the parameter table to offer intermediate output as a selection option? Without this ability, only one algorithm is possible in batch processing.

EDIT: For clarity, my problem is not with the model itself, but rather the batch processor: it does not provide the ability for an algorithm to accept, as input, the output of a previous algorithm.

inability of the batch processor to accept the output of an algorithm

  • Are you sure the model does not run correctly? The parameters for the Autofill settings are only used to create filenames for the output, it should not affect the actual processing algorithms used. I ran a similar test model and the output shapefile was correctly processed. – Joseph Nov 6 '17 at 10:34
  • Thanks for your help, Joseph. My OP may have been confusing, so I added an edit. Here's a summary of the problem: When filling out the batch process page, the autofill dropdown does not display the output from a previous algorithm. So, this works: INPUT -> ALGORITHM_1, but this does not work: INPUT -> ALGORITHM_1 -> ALGORITHM_2, because the output from ALGORITHM_1 is not available in the dropdown as input to ALGORITHM_2. Whew, that's a mouthful, I hope I've clarified things. – Stu Smith Nov 6 '17 at 17:38
  • @Joseph, in other words... how were you able to autofill the second algorithm? – Stu Smith Nov 6 '17 at 17:41
  • Ahh apologies, I misunderstood. I thought the problem was with the actual model. No you are correct, the autofill selection does not seem to offer an option for the first output. You could consider posting a feature request as I don't think it's currently possible. – Joseph Nov 7 '17 at 10:32
1

In my OP, I stated that "...the batch processor ... does not provide the ability for an algorithm to accept, as input, the output of a previous algorithm."

That statement is incorrect. The batch processor will allow the output of one algorithm to be the input of a subsequent algorithm. Thus, multiple algorithms can be daisy-chained together, with the output of one acting as the input to the next.

I misunderstood the purpose of the Autofill settings. The "Parameter to use" dropdown in the OP's second screenshot only includes the "Input layer" option, which led me to incorrectly believe that an algorithm could only accept the input layer as a data source.

Instead, the purpose of the "Parameter to use" is to provide a naming convention for the algorithm's output. For each algorithm (displayed as columns in the OP's second image) click […] in the top row of its output column. Navigate to the output layer’s desired directory. In the “Save as” window, enter a string, which will act as a prefix to the input layer name. In my example I used the string "Projected_", which is displayed under the circled number 1. If you look closely, you'll see that the output from that algorithm has the text string "Projected_" added as a prefix to each of the four input layer names. Thus:

Input layer name -> Algorithm 1 output name

QPF1029_12Z -> Projected_QPF1029_12Z

QPF1029_18Z -> Projected_QPF1029_18Z

QPF1030_00Z -> Projected_QPF1030_00Z

...

For the second algorithm (and this is where I was originally confused), repeat the same naming process as described above, but providing a different prefix. Using my OP as an example, I could have prefixed the output of the second algorithm (confusingly displayed in the first output column under the red circled 2) with something like "Centroid_", with the following result:

Input layer name -> Algorithm 1 output name -> Algorithm 2 output name

QPF1029_12Z -> Projected_QPF1029_12Z -> Centroid_QPF1029_12Z

QPF1029_18Z -> Projected_QPF1029_18Z -> Centroid_QPF1029_18Z

QPF1030_00Z -> Projected_QPF1030_00Z -> Centroid_QPF1030_00Z

...

In summary, as this batch process cycles, each of the input layers will go through the two algorithms. Each algorithm's output is named according to the prefix provided in the "Parameter to use" dropdown.

This QGIS tutorial helped me understand how to connect multiple algorithms.
Thanks also to @Joseph for his insight.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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