Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there any way to fetch the lat/long of the corners of the bounding box we got from ST_Extent?

select ST_Extent(geom) from tableName;
share|improve this question
up vote 14 down vote accepted

ST_Extent returns a box composed of xmin, ymin, xmax, ymax (bottom left, upper right coordinates):

osm=# select st_extent(way) from planet_osm_point;
 BOX(2259828.73261444 5412478.55751597,3301031.7673783 6147766.43413396)

To retrieve the point corresponding to bottom left, you can build a point composed of the bottom left X coordinate (st_xmin) and bottom left Y coordinate (st_ymin), e.g.:

osm=# select st_astext(st_makepoint(st_xmin(st_extent(way)), st_ymin(st_extent(way)))) 
      from planet_osm_point;
 POINT(2259828.73261444 5412478.55751597)

Note that since st_extent returns a bounding box, it strips of the SRID off of your geometry so you may want to add it to your newly created point (i'm using 900913 to match my OSM data's SRID):

osm=# select st_asewkt(st_setsrid(st_makepoint(st_xmin(st_extent(way)), st_ymin(st_extent(way))), 900913)) 
      from planet_osm_point;
 SRID=900913;POINT(2259828.73261444 5412478.55751597)
share|improve this answer

Your Answer


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.