I am making an atlas in Print composer and I want to check if other features besides the atlas feature are present in the map. In the Print composer map below, the (current) atlas feature is Licab, and I want to check via expression if there are other features present in the map besides Licab.

Map atlas feature question

How can I check via expression if the map contains other features besides the current atlas feature?

  • Where exactly do you want to check this? Inside the map frame you can use @map_extent variable, but this one wont work for example in a text box. Outside you can use item_variables('Map 1')['map_extent'] to get the extent. You tagged qgis-2, which version do you use?
    – MrXsquared
    Commented May 8, 2021 at 22:07
  • @MrXsquared: I created a text label below the map. I want to insert an expression in the label to return TRUE or FALSE if there are other features (besides the atlas feature) displayed in the extent of that map. I am using version 2.18.14.
    – JAT86
    Commented May 8, 2021 at 22:12

1 Answer 1


Couldnt find a solution for QGIS 2 using only expressions, I guess a custom function to get the current map extent is needed for this version (similar to item_variables('Map 1')['map_extent'] in QGIS 3). However, just in case someone is looking for a solution in QGIS 3, here is an expression:

 intersects( -- check if atlas layer and map extent intersect (by doing the following:)
  aggregate( -- to create a geometrycollection,
   layer:=@atlas_layername, -- get the desired layer and
   aggregate:='collect', -- collect
   expression:=$geometry, -- its geometry
   filter:=$id<>@atlas_featureid -- except for the current atlas feature
  ), -- closing aggregate()
  transform( -- transform
   item_variables('Map 1')['map_extent'], -- the geometry of the map extent
   item_variables('Map 1')['map_crs'], -- from the map extents crs
   layer_property(@atlas_layername,'crs') -- to the layers crs
  ) -- closing transform()
 ) -- closing intersects()
=1, -- if both geometries intersect
'TRUE', -- display true as string
'FALSE' -- and if not display false as string
) -- closing if()

Just change 'Map 1' to the name of the layout map you are using


enter image description here

Explanation: The expression aggregates the atlas layer (except for the current atlas feature) to one single geometry. Then it checks wheter this collection intersects with the current map-extent. If it does (and therefore at least one other feature is visible), it returns the string 'True'.

  • The aim of @JAT86's question doesn't seem to be checking all features but only to check whether there are some in the map extent. But i may be wrong ...
    – Snaileater
    Commented May 9, 2021 at 5:44
  • @Snaileater thats exactly what the expression does, just in the wrong version
    – MrXsquared
    Commented May 9, 2021 at 9:44
  • You aggregate all features but the atlas feature ... don't you ?
    – Snaileater
    Commented May 9, 2021 at 10:04
  • Yes, to check if at least one feature of the layer is inside the current map extent (except for the current atlas geometry)
    – MrXsquared
    Commented May 9, 2021 at 10:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.