SELECT id, ST_Box2D(areas) AS bbox FROM mytable;
In this example, the table "mytable" contains two columns: "id" is the unique id number of the row and "areas" is a geometry field containing one MULTIPOLYGON per row.
This works fine for multipolygons containing only one polygon, but some rows have polygons very spread apart, hence the bounding box is not relevant when the multipolygon contains one polygon in Europe and one in Canada for example.
So I would need a way to get one box2d per polygon per multipolygon, but I haven't found how just yet. More exactly, my goal is to return one multipolygon per row, containing one box2d per polygon.
First example
- id: 123
- area: a multipolygon containing only one oval polygon in Australia
- therefore bbox should return a multipolygon containing only one rectangle (the bounding box) in Australia
Second example
- id: 321
- area: a multipolygon containing one circle in Paris, one circle in Toronto
- therefore bbox should return a multipolygon containing one rectangle in Paris, one rectangle in Toronto