[postgis-users] Calculate Bounding Box of a point type table

Nicolas Ribot nicolas.ribot at gmail.com
Wed Aug 18 10:55:16 PDT 2010


> My fear of ST_Extent was the Note: warning in the users guide that it
> replaced the geometry metadata? And that I would have to re-set the srid
> after performing the query.
>

Hi

It does not replace the metadata, it just returns a bouding box
object, that does not keep track of the SRID.
So if you want to use st_extent in conjunction with geometries of the
table, you would have to cast it to a polygone, and to set the srid on
this polygon:

select st_asewkt(st_extent(st_geomfromtext('LINESTRING (0 0, 1 1)',
4326))::geometry);

vs

select st_asewkt(st_setsrid(st_extent(st_geomfromtext('LINESTRING (0
0, 1 1)', 4326))::geometry, 4326));

(you can use find_srid() instead of a hard-coded value, if you don't
know the geometries' SRID)

Nicolas



More information about the postgis-users mailing list