9

In the process modeler, I'd like to reference an output of a previous step as one of the parameters of an algorithm. In this case, the previous step was clipping a large raster and I want to use the clipped raster data to shift some vector data, so as the parameter to the vector transform I've got the following:

raster_value(@Clip_raster_by_mask_layer_OUTPUT, 1, $geometry)

This doesn't work. However, if I output everything from the model and then do the same transform operation manually and use 'name_of_clipped_layer' instead of @Clip_raster_by_mask_layer_OUTPUT, then it works as I expect. Is it possible to get this model to do what I want?

3
  • 1
    There's a similar question here, but it's not clear if the possible solution I posted was helpful. Please let me know if any part of my answer works for you.
    – csk
    Mar 25, 2019 at 17:52
  • I've tried most of the things you've listed in your posted answer, but I still haven't been able to get it to work. If I try and save to a known layer name, the layer ID is still unknown, so I don't know how to reference it. The problem is the same as the original if I split it into 2 models, I don't know how to do the reference to the input in the second model.
    – Paul Wicks
    Mar 27, 2019 at 16:54
  • Were you able to solve the problem? If not what version of QGIS are you using, I can give it a try.
    – mapperx
    Jun 15, 2021 at 9:30

2 Answers 2

2

I faced the same issue using QGIS 3.22, and I just gave up because nothing has worked for me. I just save the raster in some folder and then use it as input for the next step. If you work with a standard folder structure in which only the main folder will change, you can create a "file/folder" input, and then create some "Tmp" folder somewhere inside your main folder, and save your outputs there. Then you can use them as inputs for your next steps.

you can use a pre-calculated value expression to do so, it will be something like.

@projectfolder || "\\Subfolder_A\\Subfolder_Aa\\TMP\\" || "your_raster.tif".

Where @projectfolder is the variable to your "Project Folder" input, then you add your path, and finally, you add your raster (you can choose another type instead of tif.

So for your next algorithm, you use the same expression as a pre-calculated input value.

1

You have to update to at least QGIS version 3.24 to reference previous algorithm outputs using @layer_name_OUTPUT in the expression builder. In prior versions it does not work because of an unsolved issue.

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.