{"version":"1.0","type":"rich","title":"Kmeans better still, ~5 seconds for 50,000 points","description":"This example demonstrates k-means clustering of 50,000 geographic points into up to nine clusters in about five seconds. The visualization shows the resulting cluster assignments as a new column in the source data, with each point labeled by its nearest cluster centroid. The implementation uses a recursive SQL query with PostGIS functions including `ST_SnapToGrid`, `ST_Envelope`, `CDB_RectangleGrid`, and `ST_Centroid` to generate initial centroids and iteratively refine them. It leverages spatial indexing and the `<->` operator for efficient nearest-centroid lookups, updating the `occurrence_search_coords` table directly with the computed cluster IDs.","provider_name":"VizHub AI Studio","provider_url":"https://next.vizhub.com","html":"<iframe src=\"https://next.vizhub.com/viz/gist-4111438?mode=embed\" width=\"960\" height=\"500\" scrolling=\"no\" frameborder=\"1\"></iframe>","width":960,"height":500,"cache_age":3600}