5

I need to calculate centroids for each feature in a polygon layer, weighted by the values of a raster. So the centroids are shifted towards higher raster values.

I found a way, but it is complicated. Is there an existing tool which can do this?

enter image description here

3
  • 1
    Why not just iterate through each polygon, mask to polygon i, calculate a probability density function (PDF) and then take the mode. This represent a spatial process in a more relevant way. Commented Oct 28, 2021 at 13:55
  • That might work, I will try it
    – Bera
    Commented Oct 28, 2021 at 13:57
  • I have to admit that I have R or Python in mind where a vector of raster values can be modeled and indexed. In this way a pdf can be derived (eg, density, ks), the index of the mode returned along with the corresponding [x,y] coordinates. Not sure how realistic this is in QGIS but, there is likely a way for somebody savvy with the software (which is not me). Commented Oct 28, 2021 at 14:03

1 Answer 1

5

I've done similar approaches with vectors to get population based centroids. I don't know any existing tool that does this but it would be neat.

Here is another approach, it is also complicated but maybe a bit more precise than grid + variable buffer.

It is a vector based approach, basically weighting coordinates by pixel value. If there was a way to create a raster where pixel values were x and y coordinates without point conversion, would be easier.

enter image description here

And here is the result

enter image description here

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.