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?

Taras
35.7k5 gold badges77 silver badges151 bronze badges
asked Jul 20, 2023 at 6:58
2
  • Try the following expression: overlay_contains(layer:='line_layer_name', expression:='needed_field_name', filter:=is_selected()) Commented 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. Commented 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

answered Jul 20, 2023 at 8:39
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! Commented Jul 20, 2023 at 8:54

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.