[postgis-devel] Windowing Functions for Clustering

Paul Ramsey pramsey at cleverelephant.ca
Fri Dec 18 11:02:27 PST 2015


Hey Dan,
I've been reading up on the k-means cluster implementation already out
there, thinking about adding one to PostGIS (makes sense, I figure)
and one thing I've been trying to figure out is what the right API for
a clustering function is.

The k-means guy decided to do a windowing function, which I kind of like...

https://github.com/umitanuki/kmeans-postgresql/blob/master/kmeans.c#L298

So we'd put do something like,

  select gid, st_clusterkmeans(geom, 4) from geotable;

and get back a list of unique ids and cluster ids. If the user wanted
to so something after that in terms of unioning, or collecting, or
whatever, that would be up to the user to decide.

What do you think of the windowing approach, compared to the approach you took?

P



More information about the postgis-devel mailing list