Skip to content

Instantly share code, notes, and snippets.

@cecilemuller
Created March 4, 2012 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cecilemuller/1973043 to your computer and use it in GitHub Desktop.
Save cecilemuller/1973043 to your computer and use it in GitHub Desktop.
Bounding box of a MULTIPOLYGON column in PostGIS
-- If `polygons` is a column that contains MULTIPOLYGON values,
-- this returns one row per polygon.
SELECT
id AS id,
ST_Box2D((ST_Dump(polygons)).geom) AS bbox
FROM
mytable
WHERE
polygons IS NOT NULL
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment