Sunday, November 24, 2019

QGIS - Remove Neighboring features in Atlas map


Lets take a polygon layer as an example. As seen below, I need to make an atlas map showing only a single polygon feature from the states layer. So, I want only the polygon marked green to be displayed while others in red cross should be hidden.



The end result would be this...



The solution

Step 1: Add an 'id' field to the attribute table. If the 'id' field already exist, then skip this step.



Step 2: Set the layer symbology to 'Rule-based' and set the filter rule to '$id = @atlas_featureid'



Step 3: Click on 'Ok' to apply the settings. Now all the other polygon will remain hidden except the one in atlas preview.



Note: when working with atlas map layer control, you can also use rules such as these listed below:-
1) within($geometry, @atlas_geometry)
2) intersects($geometry , @atlas_geometry)


That is it!