My question is quite trivial and was discussed many times before (like here) but in our case it has the confounding extra requirements...

The list of sparsely distributed 2d point features is stored in Postgis table. The points are described with the pair of (lat, lon) geographical coordinates (WGS84, srid=4326). This data is passed through the Django ORM to the clustering software in order to determine the locations with high density of points. And it seems that this software (yet not chosen, but obviously it should be scipy or scikit-learn) consumes only pure data (but not a distance matrix).

Thus that's a problem, 'cause in our case

  1. we are required to limit the cluster diameter with a given amount of metric units (for instance, less than 10 kilometres) while our data contains the WGS84 geographical units only;
  2. it's impossible to project our WGS84 data to any of zonal UTM projection, since the data is widespread distributed all over the hemisphere (and there is no "global" UTM projection for all I know).

Now I'm looking for the approach which could meet the mentioned requirements and could produce the clusters with a desired features (see #1) for a given WGS84 data.

  • 1
    I take it you want a fairly high degree of precision? EPSG:3857 exists as global coordinate system in meters, but scale gets chronically distorted away from the poles. The problem with UTM zones is you will have issues with points that are close together but fall into two different zones. Are you OK with using plpythonu. k-means is fairly easy to implement, so you could write your own function and use ST_Distance_Spheroid to ensure that no cluster has elements >10km apart, and if so, increase k? – John Powell Oct 2 '14 at 8:05
  • 1
    The other option would be to alter the [postgresql k-means function]([github.com/umitanuki/kmeans-postgresql/blob/master/kmeans.c) to use geodesic distance instead of euclidean/planar as it does and call it in a loop, again using ST_Distance_Spheroid to ensure your 10km rule. – John Powell Oct 2 '14 at 8:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.