QGIS – Filter Visibility of Map Features Based on Atlas Coverage Layer Geometry or Attribute

atlasqgis-3qgis-atlas

When creating an atlas in QGIS, is it possible to filter map feature visibility based on the coverage layer?

What I want:

Using the image below, I want to hide the orange polygons and display only the polygons that are either intersected by the black 'coverage layer' feature or whose ID is in the coverage layer's attribute ID_LIST. The ID_LIST is a string of comma-separated numbers with no spaces.

enter image description here

What I have tried:

Using rule-based visible/else hide styling, for the 'visible' filter I've tried the following rules:

array_contains(string_to_array(attribute(@atlas_feature, 'ID_LIST' )),to_string("ID"))

The above did not work.

array_find(aggregate(layer:='MULTICOLORED_POLY', aggregate:= 'array_agg', expression:=ID, filter:=intersects( @atlas_geometry , $geometry)),"ID")

This one rendered all features.

Best Answer

My atlas feature shares a PID with the BLACKPOLYGON feature. In my final solution the black polygon feature happens to contain the features being symbolized not intersect as shown above. I suppose substituting 'intersects' for 'contains' below would satisfy the case shown above as well.

contains(geometry(get_feature('BLACKPOLYGON','PID',attribute( @atlas_feature,'PID'))), $geometry)
Related Question