For making an atlas I'd like to show different city districts, each with enclosed water bodies - one district per map (see picture).

I try to show only the part of the matching water geometry which intersects with the the city district or rather which lies only within the district so that the water does not overlap the district's border.

My idea: First step is displaying only water features which have the same district name as the district itself (before the AND-operator), the second step contains the described matter.

But I guess I imposed some wrong conditions within the rule-based symbology of my water layer. Is my expression redundant anyway?

"district"  =  attribute(@atlas_feature, 'district') AND intersection(@atlas_geometry,geometry(get_feature('districts_layer','district', attribute(@atlas_feature, 'district'))))

Does anybody know how to solve this? enter image description here

2 Answers 2


This can be done with a mask layer using the district as a mask.

So QGIS has a great symbology called inverted polygon, which will fill everything outside of a polygon.

You can also filter features based on if they are the atlas feature.

So in my example I only want to show lines that are inside my area (in red):

enter image description here

So I duplicate my area layer (right click in the layers panel and duplicate).

For this duplicate layer, set up a "Inverted Polygons" symbology. Set it to be Rule-Base with the rule of:

 $id  =  @atlas_featureid 

Set the symbology to white (or whatever you want the background colour to be) and no line:

enter image description here


enter image description here


Use a geometry generator style instead of rule-based styling.

Apply geometry generator style to water bodies layer with the expression:


enter image description here

This displays the intersection of water bodies with the current atlas feature.

enter image description here

Note that the @atlas_geometry variable is null unless the atlas preview is open in the print layout. The water bodies layer will only be visible when the atlas preview is open.

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.