简体   繁体   English

Postgis ST_Distance(最小距离计算)

[英]Postgis ST_Distance (Minimum Distance Calculation)

我有一个多边形类型的几何体,我正在计算一个POINT的最小距离,可能是在多边形几何体的内部(由360个点组成一个封闭的几何体),或者是通过postgis的ST_Distance方法在多边形几何体的外部,当POINT在几何图形外部,但是如果POINT在几何图形内部,则距离为0,无论POINT是在几何图形内部还是几何图形外部,我都希望与最接近多边形几何图形的点的距离最小。

It looks like you want the distance to the polygon shell, or the exterior ring. 看起来您想要到多边形外壳或外环的距离。 If you have a POLYGON try finding the distance to ST_ExteriorRing(poly_geom) . 如果您有POLYGON,请尝试查找到ST_ExteriorRing(poly_geom)的距离。 For MULTIPOLYGONs, see manual page for ST_ExteriorRing . 对于MULTIPOLYGON,请参见ST_ExteriorRing的手册页

If your point is inside the polygon, then its distance from it is zero. 如果您的点在多边形内部,则它与多边形的距离为零。 It sounds like you want to calculate the distance from the edge of the polygon. 听起来您想计算到多边形边缘的距离。

In that case you actually want to create a geometry that is a line, not a polygon, that is the same as the border of the polygon. 在这种情况下,您实际上要创建的几何形状是与多边形的边界相同的直线而不是多边形。 Then your ST_Distance from your point to that line will be the result you are looking for. 然后,从您的点到那条线的ST_Distance就是您要寻找的结果。

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

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