4

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:

contains( 
         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.

1 Answer 1

5

..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
  • Little addition that gave me headache for the last hour: make sure to set the same CRS for the layer and the project!
    – luidwig
    Sep 18 at 10:36

Your Answer

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

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