My model start by asking two input layer LAYER1
and LAYER2
.
Then, in field calculator for LAYER1
, i want to join an attribute value from LAYER2
. Using this code :
attribute( get_feature( 'LAYER2','ID1',"ID1"),'FIELD1')
The problem is that I'm not able to know the name of the input layer LAYER2
So I try to use the layer_property in order to see if the modeler recognize the name of yhe valeur but he won't:
layer_property( @LAYER2 ,'layerName')
But it always return a NULL value. Is there is something that you have to done to return the name of the layer?
1 Answer 1
- Make sure your layers are the Vector Layer type in your model, not just Map Layer.
- Add Vector Field elements to your model. You will be able to select the corresponding layer under Parent Layer.
- Add the Field Calculator algorithm to your model. In it, specify the appropriate layer and field being calculated. Because you've made your join attribute a model parameter, you can now call it with an '@'. I've only put
@ID
in for an example, but this could easily be aget_attribute()
expression to grab the specific feature you want.
Now when you run the model, you will be prompted to select the join field, and it should work as you intended.
-
Thanks for your time, but that's not answered my question :) I know the field name because it's normalized. But I can't know the name of the input layer. So this the formula: aggregate ('LAYER1','max',"FIELD1", intersects ($geometry, start_point (geometry (@parent))). LAYER 1 is the input layer she could be called LAYER1 or 2 or whatever but I don't know that. I need to call the layer name in order to make this spatial join. I work with the extension NETWORKS because I can't create another layer so I need to update the input layer.Lelevdl– Lelevdl2020年10月20日 07:35:36 +00:00Commented Oct 20, 2020 at 7:35
-
You say you need to call the layer name to complete the join, but that you don't know the layer name. Perhaps you have misread my answer, but that is the entire point of using model parameters to represent the field names as well as the layers. I can put any two layers and any of their fields into this model, whether I know their names ahead of time or not, and the model will still run correctly.jcarlson– jcarlson2020年10月20日 12:37:22 +00:00Commented Oct 20, 2020 at 12:37
Explore related questions
See similar questions with these tags.