I have a vector shape with many different sized polygons each with an other id and values. I want to assign a new table with Information of each polygon containing the name of the majority (higher proportion) of adjacent polygons attribute name. Ergo some kind of polygon neighborhood analysis.
The query should look to the attribute of each bordering polygon and meassure the length of neighborhood polygon and id.
Does anyone have an idea or a tool how to accomplish this task?
I intend to use QGIS, or postgis. I know there is a tool in arcgis called neighborhood statistic.
Best Answer
This blog post has the answer I think you are looking for.
In this case it looks at neighboring polygons; lists their ids, and sums up a defined attribute of them.
You might want to make a copy of the original data and then run the code in the python console of QGIS.
NOTE:
I noticed an error in his code on line 52 here is the corrected if statement:
Sample Output:
#UPDATE#
I've updated to reflect your comment.
If you load the layer into QGIS , edit the variables and output file locations, and run the following, you will get:
(showing: id, touches, length, sumcolumn)
(showing: id, length of edges summed, sumcolumn summed)
Sample Output:
1.Shared Edges:
2.Sums per polygon: