2

I'm working with 3.22.10-Białowieża and I need to create several maps of the same location, showing a different layer in each (i.e. heatmaps for different years). This is the workflow that I have set, but still needs a final fix:

  1. Create a layer (years) with no geometries and filled it with the names of the layers I want to use (an easy automated task, since the names are correlative: heatmap_1999, heatmap_2000...);
  2. Create a new print layout with the map extent I need;
  3. Create an atlas for that layout, using the years layer as coverage;
  4. Set the visibility of the layers in the Element properties of the map with the expression @atlas_pagename.
  5. Create the atlas preview, and it correctly shows each layer in each page.

So far, so good. However, I need to add a baselayer to the view and I've tried the following expression, but it doesn't work as expected:

'Base_map'||'|'||@atlas_pagename

Instead of this (obtained when the atlas preview is switched off):

enter image description here

I get this:

enter image description here

How can it be done?

Edit:

Here is a sample project (hope I've used the Project Packager complement properly). For the base layer I'm using a WMS and double-clicking on its name when constructing the expression, so misspelling shouldn't be the problem -> Well, it turns out yes: see the answer by @Babel below.

5
  • You could also use themes. I find that more useful than this approach and just need to have the theme name in a field of the atlas layer.
    – Al rl
    Sep 3, 2022 at 14:21
  • Could you please elaborate this a bit?
    – jpinilla
    Sep 3, 2022 at 14:25
  • Problem solved, see updated answer! You indeed had not the same name for the layer. Do not "double-clicking on its name when constructing the expression" - as you can see, apart from the layer's name, there is added a whole string.
    – Babel
    Sep 3, 2022 at 15:35
  • @jpinilla you create a theme for each map you want, this way you can revisit and tweak them and maintain a reliable way to update your maps. If you only want to showcase a single layer, your approach is quicker, but if you need multiple thematic maps with varying styles and layer combinations, themes are better IMO.
    – Al rl
    Sep 3, 2022 at 16:09
  • 1
    Be aware: To get the correct layer name, do not double click the layer's entry from the middle column (under Map Layers) in expression string builder, as this inserts the layer ID (name + sting), but rather use layer_property( [layer_id], 'name'), where insted of [layer_id], fill in the layer ID.
    – Babel
    Sep 3, 2022 at 18:57

1 Answer 1

2

Use this syntax: 'Base_map|'||@atlas_pagename. However, in this case, the basemap is rendered above the atlas page and will cover it.

To see the basemap in the background and the atlas features above it, use the expression in switched order: @atlas_pagename || '|Base_map'

enter image description here

As became clear when you shared your project, the problem in your case was that your Base_map layer was not properlay named. You had:

@atlas_pagename || '|Callejero_76a67408_c17f_4fd4_9fe1_bb0ec136c33f'

Use the following expression, then it works:

@atlas_pagename || '|Callejero'

Be aware: To get the correct layer name, do not double click the layer's entry from the middle column (under Map Layers) in expression string builder, as this inserts the layer ID (name + sting), but rather use layer_property( [layer_id], 'name'), where insted of [layer_id], fill in the layer ID.

enter image description here

6
  • Ummm... doesn't work either, and it should. Can't figure out what's wrong.
    – jpinilla
    Sep 3, 2022 at 14:15
  • Can you share project + data (at least sample data)?
    – Babel
    Sep 3, 2022 at 14:16
  • What exactly does not work: what do you get? Are you sure names in your coverage layer (step 1 of your question) are exactly the same as layer names: so heatmap_1999 as attribute value in coverage layer named years and layer name = heatmap_1999?
    – Babel
    Sep 3, 2022 at 14:24
  • Yes, names are exactly the same. Question edited.
    – jpinilla
    Sep 3, 2022 at 14:46
  • And basemap layer really has the same name? Not Base_map vs. base_map - that would explain the strange behaviour as it is case senstive (or any other minor difference in layer name: underscore _ vs. space ` ` etc.). For any other advice it would be good to see at least a screenshot of your layer names if not a copy of your project. Otherwise it is just guesswork...
    – Babel
    Sep 3, 2022 at 14:50

Your Answer

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

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