Multiple features per page in QGIS Atlas Layout

So, I have prepared an Atlas report with a polygon layer coverage that contains areas of the Ecological Reserve to be excluded. For each area (each record in the Exclusions layer) Atlas Layout displays a fixed table with data driven information about the area.

What I would love to do is create a Layout with two or three different areas per page, to reduce the number of pages in my appendix.

Can anyone give me some tips?

Thanks in advance

You could do this by creating a standalone table with a field like atlas_features. That field could contain a delimited string of feature IDs, like so:

FID atlas_features
1 ‘C01,C02,C03’
2 ‘C04,C05,C06’

Getting the layout / map elements to look right would require a lot of writing expressions, but it’s still possible to do it.

Styling

Use rule-based styling on your coverage layer. Create a rule like this:

 string_to_array(attribute(@atlas_feature, 'atlas_features'), ',')[0] =  "cell_id" 

Then an “ELSE” rule to get everything else. Or if you want them transparent, just omit any further rules.

Save the layer style, then create a theme with the style active.

Repeat for each map in the layout, updating the index of the string array. In my case, I’ve got three maps, so there are three layer styles corresponding to three map themes.

Layout

Maps

Make sure each map follows the themes you set.

Setting a dynamic extent is tedious, but not terrible. In the map, set an override on the min/max X and Y of the extent. Here’s the min_x, for instance:

x_min(
    geometry(
        get_feature(
            'Grid',
            'cell_id',
            string_to_array("atlas_features", ',')[0]
        )
    )
)

You can optionally add or subtract from this value to give a buffer between the feature and the edge of the map frame.

Text, etc

For the IDs, that’s easy:

string_to_array("atlas_features", ',')[0]

For other attributes, you’ve got to use the ID from the atlas to filter the actual shapes layer:

attribute(
	get_feature(
		'Grid', -- shape layer
		'cell_id', 
		string_to_array("atlas_features", ',')[0]),
	'left' -- attribute you want
)

As I said, tedious to set up. But the end result is what you want, I think? Here’s me toggling atlas pages:

atlas

2 Likes

jcarlson

Appreciated so much!
Thank you very much for your effort in helping me ! I will get a try the method you suggested.

Anyway, let me show you the methodology I’m using based on this link: https://gis.stackexchange.com/questions/439857/get-the-next-feature-in-an-atlas-using-qgis.

1 - Get the next atlas feature

New variable named “next_atlas_feature” with this code:

get_feature(@atlas_layerid,
            'ordem_num', -- field used for sorting in the atlas properties
            minimum("ordem_num", 
                    filter:= "ordem_num" > attribute( @atlas_feature, 'ordem_num' )))

2 - Duplicate for atlas feature N+1

Define new extent for duplicated map, this one is x_min for example:

with_variable (
'atlas_next_feature',
get_feature(@atlas_layerid,
            'ordem_num',
            minimum("ordem_num", 
                    filter:= "ordem_num" > attribute( @atlas_feature, 'ordem_num' ))),
x_min (geometry( @atlas_next_feature)))

I was able to automatically update the required text fields as well.

But now, my difficulty involves to create a symbology based on rules that shows not only the elements (the polygon, in this case) within the current atlas (n) [“fid” = @atlas_featureid] (for map 1, ok) but also the next feature atlas (n+1) (for map2) . I thought about adding the created variable “atlas_next_feature” to the polygon layer, but I’m not getting the desired result.

Do you know what I can do in this situation? I think I’m close to my goal, but still far away using this methodology…

1 Like

That’s where using the different styles comes in handy. You make a rule that symbolizes the current atlas feature, then right-click the layer and save the style. Then add a map theme with that style active.

Add a new style to your layer, then change the rule to target the next feature. Add a new map theme with the altered style active.

Then on your atlas, you set each map item to follow those themes. The theme will pull the specific style, and thus the rule highlighting the desired feature.

1 Like

My difficulty is in targeting the next feature. I’m not able to use an expression that works for this.

For Map 1 (C59) the expression rule is:
“fid” = @atlas_featureid

image

But For Map 2(C60) what expression would that be?
this one: [“fid” = @atlas_next_feature] does not work…

Am I forgetting something?

Something like this?

with_variable (
'atlas_next_feature',
get_feature(@atlas_layerid,
            'ordem_num',
            minimum("ordem_num", 
                    filter:= "ordem_num" > attribute( @atlas_feature, 'ordem_num' ))),
attribute(@atlas_next_feature, 'fid')
) = "fid"
1 Like

For us to visualize the result of the expression we use this for example:

attribute(eval(@atlas_next_feature), 'ordem_num')

In the “layout view”, this works perfectly (like the image below).

But for some reason, the same code apparently doesn’t work in symbology in “map view”… :frowning:

This is what i put:

"fid" = attribute(eval(@atlas_next_feature),'fid')

but the result obtained is NULL…

its a little bit tricky… probably I’ll give up and try your methodology… Thanks so much again for your help @jcarlson!

Big Hug from Portugal! :smiley: