2

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.

enter image description here

enter image description here

PolyGeo
65.5k29 gold badges115 silver badges350 bronze badges
asked Jun 25, 2023 at 10:13
2
  • 1
    It's a polyline shapefile layer Commented Jun 25, 2023 at 17:18
  • 1
    No, that's why I'm using "Load layer into project" Commented Jun 25, 2023 at 20:14

1 Answer 1

1

Use layer_property() function:

enter image description here

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).

Babel
79.7k15 gold badges96 silver badges244 bronze badges
answered Jan 28 at 3:35
1
  • I think the behaviour has to do with the fact that the variable @input_vector refers to the layer itself, whereas the Loaded 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 function layer_property(). Commented Jan 28 at 9:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.