2

I'm wondering if it is possible to use an attribute field in a QGIS Atlas coverage layer to show multiple map layers.

I know this is possible with one layer by having the layer's name in the attribute field chosen in the 'Lock layers' option:

lock layers

I know it's also possible to show multiple layers when not using an Atlas by using an expression such as:

concat ('layer 1', '|', 'layer 2')

But i've tried recreating the above in the Lock layers field to no avail i.e.:

concat layers

Also tried that with semi-colon, a list, and the '|' character.

Alternative is to use map themes to control what is shown, and this is what i'm currently doing, but it would be great to know if this other way is possible.

1
  • Hello, I have made a proposal, if it work for you can mark it as a solution, if not you can give more information to your question i could adapt answer to make it work. May 14, 2021 at 5:28

1 Answer 1

1

It work only with the name, the solution I think would be to make it the cleaner you can. The best way would be STEP 1 : get the value from expression and make it work, STEP 2 : fill the field with clean name to use it in atlas.

To get the layer name clean you can use the expression builder. The function layer_property can give you any property of each layer including name. You have to give the layer ID as the first parameter, to get it with no doubt you can double-click on the layer you want.
enter image description here

An example layer_property( 'Hebergement_touristique_14bd11cf_70fa_4d97_92cf_d51f618762f2', 'name') will give the name that would work.

Then if it work well step 2 : you complete your field with the good data. My advice is to use field calculator and creat a new field with a formula like this :

CASE 
WHEN "id" =1 THEN
  layer_property( 'Hebergement_touristique_14bd11cf_70fa_4d97_92cf_d51f618762f2', 'name')
  || '|'  ||  
  layer_property( 'Itinéraire_V9_77e2d77c_427c_40f6_8fc4_e47a8f2b6455', 'name')
WHEN "id" =2 THEN
  layer_property( 'Hebergement_touristique_14bd11cf_70fa_4d97_92cf_d51f618762f2', 'name')
WHEN "id" =3 THEN
  layer_property( 'Itinéraire_V9_77e2d77c_427c_40f6_8fc4_e47a8f2b6455', 'name')
ELSE 
  layer_property( 'Hebergement_touristique_14bd11cf_70fa_4d97_92cf_d51f618762f2', 'name')
  || '|'  ||  
  layer_property( 'Itinéraire_V9_77e2d77c_427c_40f6_8fc4_e47a8f2b6455', 'name')
END

Verify you don't have different layer with the same name and that your form field is not set as map value, the represent value and the real value would be different. Then you can be sure of your field and troubleshoot any strange character or rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.