I have two layers, a point layer and a polygon layer ('Sektorplan'
). The polygon layer attribute table has a "Sektor"
column ('1','2', ...).
The Goal
I want to add a new column ("Sector"
) to the attribute table of the point layer to indicate in which sector the point is located.
Tried so far
I used overlay_within('Sektorplan', Sektor)
in the field calculator of the point layer.
The Problem
The resulting column only shows NULL
. Using a Virtual Field or not does not make any difference. The preview of the field calculator shows up correct (['1']).
Pictures say more than a thousand words
The table of the polygon layer
Anyone knows what causes this? My search-fu failed me.
1 Answer 1
overlay_within
returns Sektor
value of the related polygon feature(s) as a list/array (even if it returns one polygon). You should convert to string.
Set Output field type
to Text
and use this expression:
array_to_string(overlay_within('Sektorplan', Sektor))
-
1Awesome! Thanks so much! Clearly did not understand that it ALWAYS returns an array.viamonster– viamonster2021年10月06日 12:03:55 +00:00Commented Oct 6, 2021 at 12:03
-
2It always returns an array since a point may be within multiple polygons., unlike your case.Kadir Şahbaz– Kadir Şahbaz2021年10月06日 12:06:36 +00:00Commented Oct 6, 2021 at 12:06
Explore related questions
See similar questions with these tags.
array_to_string()
function additionally is required i.e.array_to_string(overlay_within('Sektorplan', Sektor))