[postgis-users] Documentation on GIS specific SQL

Paul Ramsey pramsey at refractions.net
Thu Feb 20 09:43:32 PST 2003

Matt Lynch wrote:

> But it appears that I must group in order to use extent

Yes, because extent is one of two (the other is collect()) aggregate 
functions currently in PostGIS. "select extent(geom) from tbl" returns 
the aggregate extent of every feature in the table, ie. the extent of 
the table itself.

You can get the bounding box of a single geometry with either the 
OpenGIS-standard envelope() or by casting the object to a box3d with 
box3d(). You can also use the xmin(), ymin() etc functions to get the 
extents directly, which might be more convenient for accessing them from 
a database cursor, rather than parsing the values out of an envelope or 
bounding box string.


      | Paul Ramsey
      | Refractions Research
      | Email: pramsey at refractions.net
      | Phone: (250) 885-0632

More information about the postgis-users mailing list