Show only features within current Atlas feature - QGIS 3
Posted by: Admire Nyakudya | in QGIS | 5 years, 6 months ago | 0 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.

CASE
   WHEN within( $geometry , @atlas_geometry ) = 1 THEN  intersects( $geometry , @atlas_geometry )
ELSE NULL
END

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

Comments

There are currently no comments

New Comment

required

required (not published)

optional

required

Have a question? Get in touch!