In a map layout template, I want to insert an expression which gets all feature's names of a certain layer, which are contained in the current layout's view/extent. Is there a way to get an aggregate of all features of a layer which are contained in the current map view?

I've come so far, to check if a single feature of a layer is contained, but don't know how to go on from here:

         map_get(item_variables('Main Map'), 'map_extent'),
         nodes_to_points(geometry(get_feature_by_id('Corridors_86ef2ea9_d1a1_4d9f_9735_7b7b2fb54cb2', 2)))

I'm quite sure there is an expression combined with the aggregate function, which would enable me to concatenate all the names of the features in the current layout view and use this as a text item in my final layout.


..I got it! I use this expression for a composer item label with 'insert expression':

aggregate(layer:='Corridors_86ef2ea9_d1a1_4d9f_9735_7b7b2fb54cb2', aggregate:='concatenate', expression:="Name", filter:=within($geometry, map_get( item_variables('Main Map'), 'map_extent')), concatenator:=', ') 

Works like a charm:)

  • 1
    wow thanks I haven't been able to get that to work but am going to try this out... – DPSSpatial Aug 27 at 16:13
  • I'm stoked myself - QGIS 3 is really powerful! – Kay Aug 30 at 10:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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