5

Lets say I have a layer called trees, with an attribute 'species'. The set of species in my dataset is quite limited, lets say: beech, birch, oak and elm.

I want to create a report with a page for each species, and on each of those pages I want a map which only shows the trees of that species.

I prefer a solution which is able to autogenerate the pages in the report, so I won't have to manually create a layer/style/page for each species.

Is this possible?

I don't know if this is relevant to my question, but I am currently working on Shapefile layers, and would prefer not to change to other layer formats.

5

You could use a virtual layer (i.e. vtrees) to group your species into multipoint geometries.

SELECT species, CastToMultiPoint(Gunion(geometry)) as geom FROM trees GROUP BY species

enter image description here

Style your layer according the species field and the variable @atlas_pagename.

if("species" = @atlas_pagename, "species", "")

enter image description here

And create your atlas with layer vtree as coverage layer and species as page name. enter image description here

3
  • That looks great! :) But what if each tree has a label with the attribute, lets say ´age´. In your approach the atlas pages will not be able to show the label for each tree, right? I actually planned to show labels for each feature. Sep 23 '21 at 18:04
  • 1
    No problem, you still have layer trees, that you can label and filter by atlas page name. You can set symbol width to 0.
    – christoph
    Sep 23 '21 at 18:09
  • 1
    Simply copy the style of layer vtrees to layer trees and set symbol width to 0.
    – christoph
    Sep 23 '21 at 18:16
2

You can use duplicate layer withs rule-based styles (one for each species), combine that with Map Themes and create a print layout with several pages, where every page follows a map theme.

  1. Apply a rele based rendering style and set a rule like species = 'oak' so that only oaks appear (Screenshot 1, top right).

  2. Duplicate this layer three times so that you have a copy of your original layer for each specy (you don't duplicate data, it remains one file, all layers access the same shapefile). In each layer, set another species, so each layer shows only on kind of tree.

  3. Define Themes: set all layers but one to invisible, than add a new Theme and name it after the species that is visible (screenshot 1, bottom left).

  4. Create a new layout, add 3 pages to the existing one and paste a map. In Item Properties / Layers check the box next to Follow Map Theme and select the Tree you want to show. Copy this map to the other sites and change the Follow Map Theme so that every page shows another species (Screenshot 2).

enter image description here

enter image description here

3
  • Thanks. I was hoping for a solution that would auto generate the pages. But this will do as long as my lift of species is not too long. Sep 23 '21 at 14:28
  • 1
    OK, let's hope someone else comes with a handier solution. You might update your question to state that more clearly.
    – Babel
    Sep 23 '21 at 14:29
  • You are right. I have now made that clear. Sep 23 '21 at 14:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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