QGIS – How to Create Auto-Generated Reports with Maps for Each Feature Type

atlasprint-composerqgis

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.

Best Answer

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

Related Question