The Clusterfck library with haversine formula support for calculating distance, and the kmeans method modified to return the clusters along with their lengths and their centroids. Haversine coordinates should be in order of lng, lat.
Just a quick hack at the moment!