4

I'm looking for a way to identify contiguous polygons that share certain attributes (contiguously-owned parcels). I understand that in ArcGIS there is a "Polygon Neighbor" tool with a 'Report by Field(s)' parameter that would allow you to do this.

I don't just want to identify all the neighbors of each polygon, I want to identify only neighboring polygons that share a specified attribute.

2
  • If you are comfy with Python I suggest using GeoPandas to do this. I think the function to read up on would be geopandas.org/reference.html#geopandas.GeoSeries.touches - in pseudocode what would happen is, get the .touches result, and then introduce a check for sameness in the attribute(s) you identify between the 2+ rows.
    – auslander
    Dec 17, 2020 at 21:06
  • I saw a tip somewhere else that got the job done, though it required some manual cleanup since it didn't take feature adjacency into account. It involved the dissolve tool and its 'dissolve field option,' creating centroids of the original layer, and then a spatial join of the two outputs so that I could see which of the dissolved features was made up of more than one original feature. There's a better explanation here, from where I got the info: gis.stackexchange.com/a/83623/157040 Thanks! Dec 18, 2020 at 17:37

2 Answers 2

2

You can use QGIS expressions to create for each polygon feature a list of polygon neighbors with the same value for a certain field. Use this expression (e.g. with Field Calculator) and replace field on lines 11 and 12 with the name of the attribute field you want to compare:

array_to_string(
    array_remove_all( 
        array_foreach(
            overlay_intersects( @layer, $id),
            if (
                attribute (
                    get_feature_by_id (
                        @layer,
                        @element
                    ),
                    'field'
                )=field,
                @element,
                ''
            )
        ),
        ''
    )
)

Polygons, labeled with their id, the value of the field value and a list of neighboring polygon ids with the same value in the field you compare. The list of numbers in the last line of the labels is the output of the expression. So the example of polygon with id 10 (highlighted in yellow) with its 4 red neighbors that have the same value:

enter image description here

1

There are a few ways of going about this, but no single tool that I know of. You of course can create a single tool using a graphical model that employs the summary aggregate function or you could use a script that someone has already created:

https://spatialthoughts.com/2019/05/23/neighbor-polygons-aggregate-qgis/

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.