clustering
This module contains functions that perform clustering on geographies.
CREATE_CLUSTERKMEANS
Description
Takes a set of points as input and partitions them into clusters using the k-means algorithm. Creates a new table with the same columns as input
plus a cluster_id
column with the cluster index for each of the input features.
input
:VARCHAR
name of the table or literal SQL query to be clustered.output_table
:VARCHAR
name of the output table.geom_column
:VARCHAR
name of the column to be clusterd.number_of_clusters
:INT
number of clusters that will be generated.
warning
Keep in mid that due to some restrictions in the Redshift VARCHAR
size, the maximum number of features (points) allow to be clustered is around 2500.
Examples
ST_CLUSTERKMEANS
Description
Takes a set of points as input and partitions them into clusters using the k-means algorithm. Returns an array of tuples with the cluster index for each of the input features and the input geometry.
geog
:GEOMETRY
points to be clustered.numberOfClusters
(optional):INT
number of clusters that will be generated. It defaults to the square root of half the number of points (sqrt(<NUMBER OF POINTS>/2)
). The output number of cluster cannot be greater to the number of distinct points of thegeog
.
Return type
SUPER
: containing objects with cluster
as the cluster id and geom
as the geometry in GeoJSON format.
Examples
Last updated