[GIS] QGIS weighted centroid of polygons with weights from raster layer

centroidspolygonqgisraster

I am a total novice with GIS and using QGIS as that is what is available to me.

I have a vector layer of polygons (about 3500) and a raster layer of light intensity. What I'm working with looks like this:

enter image description here

I am trying to find the centroid of the polygons based on light intensity as a proxy for center of population in the polygon.

I know how to calculate the centroids of the polygons, but I am not sure how to include the values from the raster layer as weights.

I've read about clipping the raster layer based on a selection from the vector layer. I can clip a section from the raster and calculate the centroid based on the light intensity band, but I have no idea how to map that back to the original projection as the clipped raster only contains a GeoTransform (containing the coordinates for the top left corner of the rectangle that contains my polygon and some pixel extents), and a ProjectionRef (a string that I frankly understand little about).

I read Generate centroids for vector polygons based on raster and land-use data using QGIS, which makes sense. But looking at the interface for r.mapcalc in qgis I am at a loss of how to calculate the weighted centroid per polygon.

Logically I would assume that this kind of tool or method exists, but as I am a novice I don't know where to look and probably don't know how to ask properly either.

Best Answer

If you understand correctly you can create a grid, you choose a size that covers the smallest polygon ("vector grid" in toolbox) and then extracts the raster value using the grid, so use the tool "add raster values to features" in qgis toolbox. So you have a grid with raster values. Then you can extract the value of the raster using the centroid of the polygon (to compare)

We just have to think of a way to find the "luminous centroid of the polygon", I think you can do a thematic classification using a color ramp with grid values. This way you will have the most luminous points.

To get the brightest point of each polygon, you have to trim the grid with the values using the polygons and then sort them individually. then see what brightest value, filter it and save it as the centroid. I do not know if there is a fully automatic way of doing this.

Related Question