clustering
ST_CLUSTERKMEANS
ST_CLUSTERKMEANS(geog [, numberOfClusters])SELECT CARTO.CARTO.ST_CLUSTERKMEANS(ARRAY_CONSTRUCT(ST_ASGEOJSON(ST_POINT(0, 0))::STRING, ST_ASGEOJSON(ST_POINT(0, 1))::STRING, ST_ASGEOJSON(ST_POINT(5, 0))::STRING, ST_ASGEOJSON(ST_POINT(1, 0))::STRING));
-- {"cluster": 0, "geom": "{\"coordinates\":[0,0],\"type\":\"Point\"}"}
-- {"cluster": 0, "geom": "{\"coordinates\":[0,1],\"type\":\"Point\"}"}
-- {"cluster": 0, "geom": "{\"coordinates\":[5,0],\"type\":\"Point\"}"}
-- {"cluster": 0, "geom": "{\"coordinates\":[1,0],\"type\":\"Point\"}"}SELECT CARTO.CARTO.ST_CLUSTERKMEANS(ARRAY_CONSTRUCT(ST_ASGEOJSON(ST_POINT(0, 0))::STRING, ST_ASGEOJSON(ST_POINT(0, 1))::STRING, ST_ASGEOJSON(ST_POINT(5, 0))::STRING, ST_ASGEOJSON(ST_POINT(1, 0))::STRING), 2);
-- {"cluster": 1, "geom": "{\"coordinates\":[0,0],\"type\":\"Point\"}"}
-- {"cluster": 1, "geom": "{\"coordinates\":[0,1],\"type\":\"Point\"}"}
-- {"cluster": 0, "geom": "{\"coordinates\":[5,0],\"type\":\"Point\"}"}
-- {"cluster": 1, "geom": "{\"coordinates\":[1,0],\"type\":\"Point\"}"}Last updated
Was this helpful?
