Show only features within current Atlas feature - QGIS 3
Posted by: Admire Nyakudya | in QGIS | 2 years, 8 months ago | Comments

In our endless endeavour to spread QGIS, I was invited to conduct QGIS training at the Surveyor General Department in Swaziland.

Whilst teaching about map composer and atlas we wanted to show features that are within a polygon extent. A quick google search showed us that this had been answered by Underdark but her answer included showing intersecting features. In our case, we only wanted to show features that were within a polygon. 

I initially tried to use the solution that had been suggested by Underdark but the results were unsatisfactory. After trying the Underdark solution I could get the following result:

Layer Intersects

Then I thought I could just do an intersection between the Atlas geometry and the feature geometry I wanted. This solution does not work because QGIS returns a geometry collection and apparently QGIS cannot handle it properly.

The solution I finally came up with included the earlier solution from Underdark.

   WHEN within( $geometry , @atlas_geometry ) = 1 THEN  intersects( $geometry , @atlas_geometry )

The result I get is satisfactory but I would still prefer if I could use an intersection so that I can get the part of the polygon that intersects the poly rather than excluding it.

Layer within

Currently unrated


Have any questions? Contact us.
We would love to hear from you!
Subscribe to our Mailing list (spam-free, industry-relevant occasional emails)

Subscribe to our mailing list

* indicates required