1

I am trying to get specific attributes from a line layer to a polygon layer. The line layer contains a number of pipes that run through a polygon (parcel). They both have the parcel number in common:

enter image description here

The darker the color, the more pipes are within that part of the line layer. I now want to transfer the HIGHEST number of pipes into the polygon layer. What I tried so far was "Join attribute by position" - which is kind of the tool I am looking for. However, this tool is either tranfering the attribute of the first line intersecting the polygon or the one with the most length in it. There is no way to add an expression that lets me filter for the most number of pipes. Any ideas?

2
  • Try the following expression: overlay_contains(layer:='line_layer_name', expression:='needed_field_name', filter:=is_selected())
    – Taras
    Jul 20, 2023 at 7:55
  • I did not select anything, that is just my symbology (poor choice I guess). In this screenshot the orange line has a higher number as attribute than the yellow line. And that is the value that should be transfered to the polygon.
    – ibdmn
    Jul 20, 2023 at 8:01

1 Answer 1

1

you should use the aggregate expression for that:

aggregate(layer:='line_layer',
          aggregate:= 'max',
          expression:="pipe_number_field_name",
          filter:=intersects($geometry,geometry(@parent)))

see also: https://docs.qgis.org/3.28/en/docs/user_manual/expressions/functions_list.html?highlight=aggregate#aggregate

1
  • I think that's it. Was using aggregate before, but was missing the correct filter. Will do some tests but at the first look this is great!
    – ibdmn
    Jul 20, 2023 at 8:54

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.