[postgis-users] spatial extents of a PostGIS db

Kevin Neufeld kneufeld at refractions.net
Wed Mar 24 09:36:35 PDT 2010


On 3/24/2010 1:29 AM, Mike Toews wrote:
> Hi Paul,
>
> To get the bounds for one layer/table, you need an aggregate
> (ST_Collect) and envelope on the aggregate. For one layer/table, it
> would look something like:
>
> SELECT ST_AsText(ST_Envelope(ST_Collect(the_geom)))  AS envelope FROM mylayer;
>

Sorry, Mike, but I don't think you want to do this.
As an example, I have a linear table of 18 million records spanning about 12GB of data.  Your solution will try to 
create a single geometry from the entire collection (a single 12GB geometry object) and then take the envelope of it.

Rather, as Debasish Sahu suggested, use ST_Extent (http://postgis.refractions.net/docs/ST_Extent.html).

Cheers,
Kevin



More information about the postgis-users mailing list