So I start my model by dragging an input layer, which in my case it happens to be a vector layer. Let's call it inputVectorLayer. Later on in the model I want to refactor this layer using the Refactor fields algorithm. For each feature I write the correct expression, but for one feature I need an expression that should include something like this:
layer_property('inputVectorLayer', 'name')
The problem is that it doesn't recognize the name that I gave to the representation of the input layer in the Model Builder. How can I achieve this?
If I do something like this:
layer_property('actualLayerNameAsItShowsInTheLayesPanel','name')
it works, but obviously, this name changes. That's the whole point of the module, to use aliases to reference input layers.
I already tried to use double quotes to no avail layer_property("inputVectorLayer", 'name')
2 Answers 2
It might be too late but I just faced the problem today... You can do it with the layer_id:
layer_property(@layer_id, 'name')
-
Note that @layer_id only references the input layer when it is used in the first tool connected to that input. So the name will need to be stored (as an attribute) if it is required later in the model. There are variables of the parameters exposed, but a 'Vector layer' input variable is not of <layer> or <layerid> type seemingly...Andy Harfoot– Andy Harfoot2019年03月15日 14:27:36 +00:00Commented Mar 15, 2019 at 14:27
Here is a possible solution: Using input parameter as part of SQL query in QGIS model
Currently, the layer_property
function doesn't work with and input like "vectorial layer", but it works with the "vectorial objects" input. As all the other inputs work equally with this input, attributes from layer for example, if you just change the input you can get the layer properties with that function.
I hope it helps.
layer_property
function actually works. Here is a solution for something similar: gis.stackexchange.com/questions/446636/…