Name

ST_ClusterWithinWin — Fonction Window qui renvoie un identifiant de cluster pour chaque géométrie en entrée, regroupement en utilisant la distance de séparation.

Synopsis

integer ST_ClusterWithinWin(geometry winset geom, float8 distance);

Description

A window function that returns a cluster number for each input geometry. Clustering partitions the geometries into sets in which each geometry is within the specified distance of at least one other geometry in the same cluster. Distances are Cartesian distances in the units of the SRID.

ST_ClusterWithinWin is equivalent to running ST_ClusterDBSCAN with minpoints := 0.

Disponibilité : 3.4.0

Cette méthode prend en charge les types Circular String et Curve.

Exemples

WITH testdata AS (
  SELECT id, geom::geometry FROM (
  VALUES  (1, 'LINESTRING (0 0, 1 1)'),
          (2, 'LINESTRING (5 5, 4 4)'),
          (3, 'LINESTRING (6 6, 7 7)'),
          (4, 'LINESTRING (0 0, -1 -1)'),
          (5, 'POLYGON ((0 0, 4 0, 4 4, 0 4, 0 0))')) AS t(id, geom)
)
SELECT id, 
  ST_AsText(geom), 
  ST_ClusterWithinWin(geom, 1.4) OVER () AS cluster 
FROM testdata;


 id |           st_astext            | cluster 
----+--------------------------------+---------
  1 | LINESTRING(0 0,1 1)            |       0
  2 | LINESTRING(5 5,4 4)            |       0
  3 | LINESTRING(6 6,7 7)            |       1
  4 | LINESTRING(0 0,-1 -1)          |       0
  5 | POLYGON((0 0,4 0,4 4,0 4,0 0)) |       0

        

Voir aussi

ST_ClusterWithin, ST_ClusterDBSCAN, ST_ClusterIntersecting, ST_ClusterIntersectingWin,