I have a dataset of 488 GPS points which I would like to break up into small clusters. The maximum number of points per cluster should be 3.

I have tried the K-means clustering tool in Vector Analysis, however this does not give me the option to set a maximum amount of points, only a minimum. Similarly I have tried the ConcaveHull plugin, but I don't think a maximum number of points can be set with this either.

I am using QGIS.

  • If you wish to ask about ArcMap or R then please do that in a separate question and for the latter include a code attempt.
    – PolyGeo
    Jun 30, 2023 at 10:50
  • Any other rules? Minimum number of points? Maximum distance? As it stands your requirements could be satisfied by 488 clusters of 1 :) Oct 12, 2023 at 5:05

1 Answer 1


I recently had a similar challenge. When searching, I found the python script from the link at https://spatialthoughts.com/2021/01/31/equal-sized-kmeans-qgis/. See if it works for you.

  • 1
    Please expand your answer by including a code section and explaining why this solution solves the issue. Just posting a link isn't really an answer, it's more of a comment. Please see here on how to give a good answer.
    – Nikos
    Oct 12, 2023 at 10:30

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.