简体   繁体   English

从 POLYGON 对象中获取最小/最大点数

[英]Get min/max POINTs from a POLYGON object

I have a table with a geom column containing polygons.我有一个包含多边形的geom列的表。 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.这个想法是在数据库中创建minLatmaxLat等列,以加快搜索速度。

I resolved it by using ST_Envelope(poly)我使用 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))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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