2

I'm having a polygon-file of all municipalities in Bavaria, with data of population density. Now I want to get a value for each polygon (= each municipality) that shows the average of population density of all neighboring polygons plus the source polygon.

I am working in QGIS. My knowledge is quite basic. Can anyone help? As I want to get the value for all municipalities of Bavaria, I can't do this operation by hand.

2

As a basis you can use the script provided in this tutorial http://www.qgistutorials.com/de/docs/find_neighbor_polygons.html

By default it writes the sum of an attribute to the table, so if you want the average of the population density, you need to adjust on of the last lines from f[_NEW_SUM_FIELD] = neighbors_sum to f[_NEW_SUM_FIELD] = neighbors_sum/len(neighbors)

Then you should get your desired result, however note that I currently had not the time to test my solution, so maybe you need to adjust some other parts of the script too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.