简体   繁体   中英

Get min/max POINTs from a POLYGON object

I have a table with a geom column containing polygons. eg:

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.

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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM