Skip to content

Instantly share code, notes, and snippets.

@andrewxhill
Created February 23, 2012 16:27
Show Gist options
  • Save andrewxhill/1893544 to your computer and use it in GitHub Desktop.
Save andrewxhill/1893544 to your computer and use it in GitHub Desktop.
Creates a bounding circle from the_geom_webmercator on cartodb
WITH inp as ( SELECT ST_Centroid(ST_Collect(ST_envelope(the_geom_webmercator))) as centroid,
ST_ConvexHull(ST_Collect(ST_Envelope(the_geom_webmercator))) as hull
FROM table_name GROUP BY some_column)
SELECT ST_Buffer(centroid,
ST_Length( ST_LongestLine(centroid, hull))) as the_geom_webmercator
FROM inp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment