2

I have a multi-polygon consisting of the second administrative units of the DRC, Uganda, and Burundi, each identified by a field id (fid).I need to find the neighboring polygons for each fid. There are some online sources on how to do this, e.g., https://spatialthoughts.com/2019/05/23/neighbor-polygons-aggregate-qgis/
I tried the following approach using the field calculator :

aggregate(
layer:= 'MAP',
aggregate:='concatenate',
expression:=to_string("fid"),
concatenator:=', ',
filter:=intersects($geometry, geometry(@parent))
) 

In the beginning, this approach looks promising and the preview of the out seems right (23,42,43). However, when I perform the analysis the newly created variable has the value NULL in every row. I read that this is sometimes caused by the polygons not touching each other and can be solved by creating a buffered version of my initial layer. This unfortunately did not solve the problem.

2
  • 4
    Is the datatype of your output field set to Text? Perhaps the expression works but it is trying to insert strings into a number field.
    – Matt
    Jan 26, 2023 at 11:07
  • That solved it!
    – KC15
    Jan 26, 2023 at 11:25

0

Browse other questions tagged or ask your own question.