1 | | Proposal for two clustering functions: |
| 1 | = Proposal for clustering functions = |
| 2 | |
| 3 | == `geometry[] ST_ClusterIntersecting(geometry geom)` == |
| 4 | |
| 5 | Aggregate function returning an array of `GeometryCollection`s representing the connected components of a set of geometries. |
| 6 | |
| 7 | - 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...) |
| 8 | - return a geometry array (my current implementation returns a `GeometryCollection`, but the recursive semantics of `ST_Dump` then undo all of the hard work) |
| 9 | Example: if run on a table containing all of the `LineString`s in the image below, would return an array with two `MultiLineString` geometries (red and blue) |
| 10 | |
| 11 | [[Image(http://i.stack.imgur.com/WNlxX.png)]] |
9 | | - accepts Point/MultiPoint, LineString, MultiLineString, Polygon, MultiPolygon geometries of any type that can be converted into GEOS (I can't think of a situation where Point/MultiPoint would be useful, but that doesn't mean there isn't one...)[[br]] |
10 | | - return a geometry array (my current implementation returns a GeometryCollection, but the recursive semantics of ST_Dump then undo all of the hard work)[[br]] |
11 | | 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) |
| 19 | - 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. |
| 20 | - differs from k-means in that a distance is provided, not a number of clusters |
15 | | |
16 | | ---- |
17 | | |
18 | | |
19 | | {{{geometry[] ST_ClusterWithin(geometry geom, double precision distance)}}} |
20 | | |
21 | | 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. |
22 | | |
23 | | - 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.[[br]] |
24 | | - differs from kmeans in that a distance is provided, not a number of clusters[[br]] |
25 | | |
26 | | 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. |
27 | | |
28 | | [[http://ibin.co/1oH1ApWCoW8L]] |
| 24 | [[Image(http://ibin.co/1oH1ApWCoW8L)]] |