wiki:DevClusteringFunctions

Proposal for clustering functions

geometry[] ST_ClusterIntersecting(geometry geom)

Aggregate function returning an array of GeometryCollections representing the connected components of a set of geometries.

  • accepts [Multi]Point, [Multi]LineString, [Multi]Polygon geometries of any type that can be converted into GEOS (I can't think of a situation where [Multi]Point would be useful, but that doesn't mean there isn't one…)
  • return a geometry array (my current implementation returns a GeometryCollection, but the recursive semantics of ST_Dump then undo all of the hard work)

Example: if run on a table containing all of the LineStrings in the image below, would return an array with two MultiLineString geometries (red and blue)

http://i.stack.imgur.com/WNlxX.png


geometry[] ST_ClusterWithin(geometry geom, double precision distance)

Aggregate function returning an array of GeometryCollections?/MultiPoints?, where any component is reachable from any other component with jump of no more than the specified distance.

  • like ST_ClusterIntersecting, but uses a distance threshold rather than intersection when determining if two geometries should be included in the same component. Could have an implementation very similar to ST_ClusterIntersecting, or could be restricted to points and maybe have a more efficient implementation.
  • differs from k-means in that a distance is provided, not a number of clusters

Example: In the picture below, an array of five MultiPoints would be returned (color-coded). The threshold distance in this case was more than the orange line but less than the pink line.

http://ibin.co/1oH1ApWCoW8L

Last modified 10 years ago Last modified on 02/02/15 12:41:18
Note: See TracWiki for help on using the wiki.