Skip to content

Instantly share code, notes, and snippets.

@strk
Last active August 29, 2015 13:55
Show Gist options
  • Save strk/8693074 to your computer and use it in GitHub Desktop.
Save strk/8693074 to your computer and use it in GitHub Desktop.
WITH clusters AS (
SELECT
ST_Collect(the_geom_webmercator) as g,
count(*) as count
FROM the_tornados WHERE the_geom_webmercator && !bbox!
GROUP BY ST_SnapToGrid(the_geom_webmercator, greatest(!pixel_width!,!pixel_height!)*48)
)
SELECT row_number() over () as cartodb_id,
count,
least(100, greatest(count,10)) as size,
ST_Centroid(g) as the_geom_webmercator
from clusters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment