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;


And for multiple layers/tables, you need some unions and subqueries:

SELECT ST_AsText(ST_Envelope(ST_Collect(sub_envelope))) AS envelope
FROM
    (
    SELECT ST_Envelope(ST_Collect(the_geom)) AS sub_envelope FROM layer1
    UNION ALL
    SELECT ST_Envelope(ST_Collect(the_geom)) AS sub_envelope FROM layer2
    )
AS envelopes_from_several_layers;

Which does the envelope of several sub-envelopes. Make sure they all
share the same SRIDs.

-Mike

On 24 March 2010 00:30, Malm Paul <[email protected]> wrote:
> Hi List!
>
> I have imported a map with ogr2ogr to a "PostGIS" db, is there a way to find 
> out the spatial extent of this map e.g the envelope that is build from all 
> including layers?
>
> Kind regards,
> Paul
> _______________________________________________
> postgis-users mailing list
> [email protected]
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>
_______________________________________________
postgis-users mailing list
[email protected]
http://postgis.refractions.net/mailman/listinfo/postgis-users

Reply via email to