The kmeans extension offers several clustering algorithms for working with geospatial data in PostgreSQL/PostGIS.