3

I have a table with a geom column containing polygons. e.g.:

POLYGON((-104.98075 25.83706,-84.659531 25.83706,-84.659531 49.38449,-104.98075 49.38449,-104.98075 25.83706)),4326

How can I extract the minimum and maximum latitude and longitude values from that object, as floats? The idea would be to create minLat, maxLat, etc., columns in the DB to make searching a bit quicker.

Colin
  • 2,109
  • 1
  • 20
  • 22

1 Answers1

1

I resolved it by using ST_Envelope(poly)

select ST_Envelope(poly) from table WHERE id=1;

This returns a polygon with the corners of the contained polygon.

POLYGON((
-90.79440777754286 14.37717780192112,
-90.78941725049431 14.37717780192112,
-90.78941725049431 14.3808399138696,
-90.79440777754286 14.3808399138696,
-90.79440777754286 14.37717780192112))
JoeGalind
  • 3,545
  • 2
  • 29
  • 33