title: PostGIS: bounding box of a multipolygon
body: <pre><code>SELECT id, ST_Box2D(areas) AS bbox FROM mytable;
  </code></pre>
  
  <p>In this example, the <strong>table</strong> "mytable" contains two columns: "<strong>id</strong>" is the unique id number of the row and "<strong>areas</strong>" is a <em>geometry</em> field containing one <em>MULTIPOLYGON</em> per row.</p>
  
  <hr>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <hr>
  
  <p>First example</p>
  
  <ul>
  <li><strong>id</strong>: 123</li>
  <li><strong>area</strong>: a multipolygon containing only one oval polygon in Australia</li>
  <li>therefore <strong>bbox</strong> should return a multipolygon containing only one rectangle (the bounding box) in Australia</li>
  </ul>
  
  <hr>
  
  <p>Second example</p>
  
  <ul>
  <li><strong>id</strong>: 321</li>
  <li><strong>area</strong>: a multipolygon containing one circle in Paris, one circle in Toronto</li>
  <li>therefore <strong>bbox</strong> should return a multipolygon containing one rectangle in Paris, one rectangle in Toronto</li>
  </ul>