I am looking for a method of clustering XYZ data in Python that works on numpy arrays. I know of a few sources, such as clusterpy and Pysal but have had little success with them as they seem to still be in the development stage and do not support numpy arrays.


My numpy arrays are of XY points with a Z column of a value at the point such as soil moisture or plant height. I want to spatially cluster the Z values into similar regions.

  • 1
    I haven't tried it but what about scipy? Also, what problems are you having with what you've tried? PySAL is fairly well established.
    – Fezter
    Commented Jun 26, 2014 at 23:36
  • I am looking for clustering routines that are designed for GIS data, hence the usage of the mentioned libraries. I think clusterpy is completely broken, and Pysal currently only implements the max-p algorithm. Commented Jun 30, 2014 at 13:49

1 Answer 1


scikit-learn has an extensive clustering library with many different methods available. As a bonus scikit-learn is one of the best documented Python libraries I've seen. When working with 3d point clouds I've had a lot of success with DBSCAN for instance.

Alternately as @Fezter suggests above, scipy offers two different methods of clustring: k-means (vector-quantization) and hierarchical classification. While there isn't the number of methods available scipy is often a good place to start as the clustering methods don't tend to require as much setup.

  • I am looking for cluster libraries for GIS data, see my edit. Commented Jun 30, 2014 at 13:51

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.