9

I need to get the weighted centroid from a grid layer (according to an attribute of the polygons on this layer). For that, I am using the "mean coordinates" tool, but I realized that the yielded points are displaced from the place they should be located. This is clear when I apply a mean coordinate to just one feature, like in the image:

Feature with centroid (orange) and point yielded by mean coordinates tool (red)

The red point is the one yielded by the mean coordinates, while the orange one appears to be the logic centroid for the selected feature (yellow piece from grid). Distance between both points is around 20m, but this distance it's not always the same for other cases (even though it's around that value).

Can this be due to having a different CRS for the grid from the project one?

4
  • Welcome to Geographic Information Systems! Welcome to GIS SE! We're a little different from other sites; this isn't a discussion forum but a Q&A site. Your questions should as much as possible describe not just what you want to do, but precisely what you have tried and where you are stuck trying that. Please check out our short tour for more about how the site works
    – Ian Turton
    Apr 3, 2023 at 10:44
  • 1
    what did you set as the weight?
    – Ian Turton
    Apr 3, 2023 at 10:45
  • Yes, CRS might be the reason. Use same CRS for layer and project
    – Babel
    Apr 3, 2023 at 10:47
  • 1
    "Can this be due to having a different CRS for the grid from the project one?" - this is easy to test and you may answer your own question
    – Matt
    Apr 3, 2023 at 10:47

1 Answer 1

13

Can this be due to having a different CRS for the grid from the project one?

I don't think so. This is more likely caused by that the polygon starts and ends in the lower left corner. (that means there are two points there), or there are other points (vertex) there. A polygon having n vertices has n+1 points in QGIS.

You can test it by creating polygons starting from different corner:

enter image description here

1
  • 1
    Makes sense, didn't know that. Therefore, in order to obtain the weighted centroids, I first get centroids for each grid feature, then obtaining the mean coordinates from those centroids. Just tested, the result is good. Thank you so much!
    – Jaime S
    Apr 3, 2023 at 12:13

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.