3

I am trying to find a location that minimises the total distance to a series of points, and compare it with the distance to an existing location. I used the QGIS tool mean coordinate(s) to calculate the centroid and then calculated a distance matrix to the centroid and the existing location. I expected the sum of distances to the centroid to be shorter than the sum of distance to the existing location but this is not the case. I've tried with a WGS and a projected coordinate system (I guess results are only valid for the second) and in both cases the centroid did not minimise distance. Is my procedure flawed ?

2

The mean coordinate minimizes the sum of the square of the distance to each point, not the sum of the distances.

To illustrate why it is wrong to use the centroid, let's think that you have 2 points at the same location 0;0 and 1 point at 0;6. The average is 0;2 and the sum of the distances is 2+2+4=8. If you consider the best location as being 0;0, the sum of the distances becomes 0+0+6=6, which is better.

To solve your problem, you may want to search for algorithm solving the Weber problem. This post is also interesting.

  • Thanks! do you know if there's a library or tool to solve the weber problem either using QGIS or python directly? I have not seen any. – Nabla Oct 2 '17 at 4:04

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.