Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Is there an easy way to get the bounding box for an entire table in PostGIS?

Thanks

share|improve this question
add comment

2 Answers

ST_Extent should do the trick.

ST_Extent — an aggregate function that returns the bounding box that bounds rows of geometries.

Applied like this:

SELECT ST_Extent(the_geom) as table_extent FROM your_table;
share|improve this answer
add comment

As @underdark post, st_extent will do the job, but be aware that it will not return a geometry. If you need a geometry type you should use something like

SELECT ST_SetSRID(ST_Extent(the_geom),THE_SRID) as table_extent FROM your_table;

Also if what you need is get the bounding box of each of the rows i think that you can use this sentence:

SELECT ST_SetSRID(ST_Extent(the_geom),THE_SRID) as table_extent FROM your_table GROUP BY gid;

Assuming that gid is the primary key of the table

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.