I am designing a simple model to automate the loading and styling of new layers in a QGIS project. The idea is to use "Set layer style" to apply style settings from a QML file then load the layer into the project. I cannot, however, figure out how to add the layer to the project using layer's filename. The only thing that works is setting a static name ("Value") in "Loaded Layer Name", but this would be the same for every layer loaded. I've tried using a Pre-Calculated Value with the name of the input (@Input_vector), but this does not work.
This seems to be related to issues recalling the variables associated with inputs, but I can't find any workable solution.
-
1It's a polyline shapefile layerMatt– Matt2023年06月25日 17:18:19 +00:00Commented Jun 25, 2023 at 17:18
-
1No, that's why I'm using "Load layer into project"Matt– Matt2023年06月25日 20:14:04 +00:00Commented Jun 25, 2023 at 20:14
1 Answer 1
Use layer_property()
function:
Alternative: @layer_ids[0]
(or your Layer number).
I am learning myself, so hope to hear as well on why just @input_vector
produce Null.
Set_layer_style seems to work without including into dependencies (comment if/when have to be otherwise).
-
I think the behaviour has to do with the fact that the variable
@input_vector
refers to the layer itself, whereas theLoaded layer name
requires a textstring (layer's name), not the refererence to a layer which is not a string. That's why you have to call the name using the functionlayer_property()
.Babel– Babel2025年01月28日 09:19:33 +00:00Commented Jan 28 at 9:19