4

I'm trying to achieve auto-listing of features visible (ie rendered and in Map's extents) in a text field rendered as HTML. My idea is:

  1. Adding attribute's table to print composer, setting it to show only features visible (this would be just good enough), but I have to format it kinda in this way (ie all values should go as a into cell labeled as Befundnummer):

enter image description here

  1. Getting all the values from said table into the concatenated string and importing it to the text field with some cleaver expression like those I already have for map scale and coordinate sys:
<td>Maßstab:</td><td>1:[%round(map_get(item_variables('Mapa 1'), 'map_scale'),0)%]</td>
</tr>
<tr>
<td>Koordinatensystem:</td><td>[% @project_crs %]</td>
</tr>
  1. Hiding the attribute table so it doesn't interfere with the final export.

Is this possible without writing any elaborate functions?

//Edit: I'm adding some more info about data structure Table of attributes of that layer is quite simple, as it only has 2 columns, ID (the befund number, integer) and a class (type of feature, string data).

enter image description here

I'm adding a table of attributes in print composer, linking it with polygonal layer with those Befunds. After checking box at 'show only features visible on map' and getting rid of header I'm pretty much good. enter image description here

And table object is rendered like that with constant update:

enter image description here

The point is, that I'd like to fit it into the label mentioned above, optimally as a self-updating string that would resemble 'id', 'id', 'id'. At this point I'm thinking about really painful workaround (ie splitting the table into one-cell-frames and modify integers to have commas)...

5
  • Which QGIS version?
    – Stu Smith
    Jun 15, 2021 at 16:03
  • 3.18 Zurich, edited my question! Jun 15, 2021 at 16:13
  • Can you show example of what befund number should look like ? Would you like the id of feature to be shown or wich field name ? (To make an answer that you could implement easily) Jun 15, 2021 at 18:22
  • @CorentinLemaitre thanks! I've added more infos about - big word - data structure, tbh I think I'll be able to edit my stuff into the expression, it's the syntax in generall that freightens me. Jun 15, 2021 at 19:16
  • If it doesn't work can you explain wich result you get ? Jun 17, 2021 at 11:00

1 Answer 1

2

You plan to use the attribute table in the layout and then extract it content in a text field, it is smart but I think it will not be easy to do as features in your layout are very independent.

The solution I proposed is based on an expression that will calculate directly the result you want. The result could be integrated in a text field as you have done for Maßstab or Koordinatensystem.

This process is doing an intersection joining "on the fly" so you need to have the same CRS for atlas layer and target layer. If you don't then you have to add an expression to handle it and it is getting even more complicated.

First to extract features that cross the current atlas feature :

array_to_string(
  aggregate(
    'poly plan 2', 
    aggregate:='array_agg', 
    expression:="id", 
    filter:= intersects( 
      @atlas_geometry,
      $geometry
    )
  )
)

To extract features that cross the map extent in your layout, then you have to change the geometry used by the intersect. The CRS need to be the same in your target layer and in the map integrated in your layout.

array_to_string(
  aggregate(
    'poly plan 2', 
    aggregate:='array_agg', 
    expression:="id", 
    filter:= intersects(
      map_get(item_variables('Mapa 1'),'map_extent'),
      $geometry
    )
  )
)

Note : If your map item in the layout have another name, then you must change the text Mapa 1.

1
  • Preferably 'an array aggregation of the features visible in the map object current extense', which would allow the user to apply this trick both for atlas bulky exports (no matter the method of scale setting) and manual exports, but the intersection should do the trick with atlases based on some separate layer. Thanks, this is inspiring, looking forward for sequel of your answer! Jun 15, 2021 at 22:54

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.