Explore Kartoza

Try searching for: QGIS, Training, GeoNode, PostGIS

Show Only Features Within Current Atlas Feature - QGIS 3
Back to Blog
QGIS Atlas
May 15, 2019 Admire Nyakudya

Show Only Features Within Current Atlas Feature - QGIS 3

Kartoza conducted QGIS training at the Surveyor General Department in Swaziland, where the team explored filtering features within polygon extents.

Show Only Features Within Current Atlas Feature - QGIS 3

QGIS

Overview

Kartoza conducted QGIS training at the Surveyor General Department in Swaziland, where the team explored filtering features within polygon extents during map composer and atlas work.

The challenge involved displaying only features contained within a polygon boundary. An existing solution from Underdark showed intersecting features, but the training team needed a stricter filtering approach.

Initial attempts using Underdark’s method produced undesirable results showing intersections. Attempting geometry intersection proved problematic because “QGIS returns a geometry collection and apparently QGIS cannot handle it properly.”

Final Solution

The working formula combines conditional logic with spatial operators:

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

This approach successfully filtered features contained entirely within the atlas polygon. However, the author noted a preference for pure intersection methods to capture partial polygon overlap areas rather than complete exclusion.

The solution produced satisfactory results, though the team acknowledged limitations in handling geometry collections that prevented more elegant alternatives.

Want to Learn More?

Explore our training courses or get in touch to discuss how we can help your organization.