In QGIS 3.34.4 I have 2 layers, one underlying layer (Layer 1) and an overlapping layer (Layer 2).
Both layers are polygon layers. I want to get the specific data of one field from layer 1 to a field in layer 2. Many polygons from layer 2 are overlapping multiple objects from layer 1. I want this done automatically via the attribute form.
I know that
array_to_string(overlay_within( 'layer 1', "field" ))
can get me the results when the polygon of layer 2 only overlaps with a single polygon of layer 1, but whenever the polygon overlaps with multiple objects from layer 1 there is no result. This should be preferably displayed as follows: " value1 , value 2 , value3 ..." Some polygons have the same value, is it at all possible to show each value only once?
If it helps to understand: I want to display all the plot owners of the property underneath the planned project.
I am new to GIS and my QGIS is in another language.
1 Answer 1
You are using overlay_within
so it will return something only for polygons from layer 2 that are totally included in at least one polygon from layer 1. To be within several polygons from layer 1 means that those layer 1 polygons overlap themselves, if that is not the case, getting no result is the expected result with your expression.
To get a result for polygons from layer 2 that overlap several polygons from layer 1 you should use the overlay_intersect
function:
array_to_string(overlay_intersect( 'layer 1', "field" ))
To remove duplicate values from the result you may add an array_distinct
function to your expression :
array_to_string(array_distinct(overlay_intersect( 'layer 1', "field" )))
You may also want to order the result with the array_sort
function:
array_to_string(array_sort(array_distinct(overlay_intersect( 'layer 1', "field" ))))
Explore related questions
See similar questions with these tags.