I have made an atlas in QGIS 3.6.3 (Noosa) of plant species distributions in two periods of time. Black dots represent distribution in the period 2000-2019 and gray squares represent distribution in the period 1975-1999 (see picture below). In the top part the local (Dutch) name, the scientific name and an ecological group indicator are shown. This is printed automatically using a reference dataset.

I want to print the number of black circles and the number of gray squares as text automatically for every map (1700 maps total). Can this be done without having to calculate it manually? In Excel or R i am able to make a column that specifies the number of occurences in the given period. I could then print this number in the print composer, but the map is still a work in progress and i would not want to manually update it every time i make a change in my dataset (add a new square for a species for example). Hence i would like a way to have the number of features calculated for me automaticcaly whilst generating the Atlas.

Concrete question: How can I print the number of black dots and gray squares in a text block (see example in bottom right of added picture), using the atlas generator in QGIS?

Hope the question is clear enough, otherwise i am open to suggestions.

enter image description here

Coverage layer (Text file with no geometrics): enter image description here

  • what is the coverage layer of your atlas ?
    – Snaileater
    Commented Jul 17, 2021 at 13:10
  • I have two coverage layers: a shape with points for dispersion in period 1975-1999 and a shape with points for the dispersion in period 2000-2019. Commented Jul 17, 2021 at 13:33
  • 1
    that's not my question : a qgis atlas uses a coverage layer which is a polygon layer containing the "views" (areas) you want to have ("hover") in your atlas. a "page" of your atlas will then be an area of your coverage layer. You can do then calculations per area (page) and display them per area (page). So in fact i'm not sure u're really referring to a qgis atlas.
    – Snaileater
    Commented Jul 17, 2021 at 13:58
  • Sorry for misunderstanding. I though the coverage layer was the layer that provided the cover data, i.e. the points of individual species. My coverage layer (which has the name reference layer (translated) in my version) is a file with individual species names and some information on ecological codes. I post a screenshot of it in the op. Commented Jul 17, 2021 at 14:18
  • 1
    @Snaileater: The atlas function does not only work for a set of maps covering a region with several maps, but also for creating a set of maps with identical extent but different contents. I once did something similar with a set of distribution maps for different bird species covering one identical area. In this case, the "Coverage" layer has no geometries - so its just a list of attributes just like Stevestingray posted above. An atlas coverage does not need necessarily geometric information (although this is the standard case) but anythng iterable works as coverage layer.
    – oekoplaner
    Commented Jul 17, 2021 at 18:05

2 Answers 2


Here is my understanding of your question and then the solution I propose.

Your goal

You have to produce 1700 maps always about a given region (the island shown in screenshot).

In this maps theres is two_layer

  • black circle in layer_a for every plant species distribution 2000-2019
  • grey square in layer_b for every plant species distribution 1975-1999

I consider that these layers are polygon and contain a column named eco to code the species. The goal is to count the number of feature in layer_a and in layer_b if we filter only a given plant species (one for each atlas).

We assume that for a given species and a given period of time OR for a given layer there is no overlapping of feature (multiple feature in the same place with same attributes).

How to do it

First update QGIS. There is not all the aggreagate expression in the 3.6 version.

Define your layout and coverage layer for atlas. This layer have a comon field with layer_a and layer_b wich is eco.

Create a text box in your atlas, insert an expression wich will be : aggregate( 'layer_a', 'count', 1, filter:= "eco"= attribute(@atlas_feature, 'eco'))

Note : you have to select layer_a text and then double click on your layer corresponding to insert his name (it will prevent miswriting of layer name).

enter image description here

This will count the number of feature in layer_a that have the field eco equal to the eco value of your current atlas feature.

Do the same for the value in layer_b and arrange your text format.

Optional : If you have features in layer_a or layer_b that are outside your current map, then you can add in the expression a filter based on geographical rule.

  • 1
    Thanks for the very comprehensive explanation! This is indeed what i was looking for. Took me a while to find the time to try it (sorry for that), but it works like a charm! Thanks also for pointing out the aggregate function is not available in my previous version. After an update, it's there. :) Regards! Commented Jul 20, 2021 at 12:33

I do not really understand the structure of your data sets.

You have posted your "coverage" layer - seems ok for me.
I understood, that you have two shape files with points for dispersion of your plant species. Is this correct?
I Think, you must have a layer with the squares covering your area of interest.

Now for your problem:
If I understand it correctly, you need a column with a virtual field in your coverage table that counts the occurences of a species in one of the periods. I think you should read about the function "aggregate" ( https://docs.qgis.org/3.16/en/docs/user_manual/working_with_vector/functions_list.html#aggregate ). This function allows you to collect and - well - aggregate informations from another layer. I don't know the details of your data structure, but I am quite sure, that this function can do what you need.

Maybe something similar like

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.