I find the processing modeller extremely challenging to work with, and not as well documented as I'd like it to be. Since my first suggestion didn't work, I have a couple of other suggestions.
This was my first suggestion, which didn't work:
Intermediate output layers are usually called something like
'Toolname of layername'
. Eg, the output of running the clip
tool
on a layer called 'vectorlayer', is probably called something like
'Clip of vectorlayer'
. You can find the exact name of an
intermediate output by adding any algorithm that would let you choose
the intermediate output as input from a dropdown menu. Make a note of
what the intermediate outputs are called, and use that name in your
difference()
expression.
Suggestion number two:
I wonder if the issue could be as simple as that the it's expecting a string for 'LayerB', but the string 'Difference' from algorithm 'Building_frontbuffer'
because has single quotes inside it. So if you used ''Difference' from algorithm 'Building_frontbuffer''
for 'LayerB', I believe it would be interpreted as three separate strings, with gibberish in between.
- first string:
''
- gibberish:
Difference
- second string: `' from algorithm '
- gibberish:
Building_frontbuffer
- third string:
''
If this is the issue, you need to escape the single quote characters, so the expression can understand the entire layer name ('Difference' from algorithm 'Building_frontbuffer'
) as a single string.
According to this Q&A, Is there an escape option for single quotes & apostrophes in QGIS?, you can just put single quotes around a string with single quotes in it. I wouldn't have thought that would work, but it's worth trying:
''Difference' from algorithm 'Building_frontbuffer''
Note that the string starts and ends with two single quote characters, not one double quote character. (''
is '
twice, not "
)
If that doesn't work, try escaping the single quote with \
, like this:
'\'Difference\' from algorithm \'Building_frontbuffer\''
(Based on suggestions from this Q&A on stackoverflow: Replacing an apostrophe in a string.)
Suggestion number three:
As a workaround, make the 'difference' output a permanent layer. Define the layer name and filepath with a string input. This way you know exactly what the layer is called, so you can use the correct layer name in the expression.
Final suggestion:
If none of the above suggestions works, and you can't find a solution, you just have to end the model at this point. Make the final output of your model a permanent layer from 'Difference' from algorithm 'Building_frontbuffer'. Put the rest of your steps from the original model into a new model.