Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. User Manual
  5. Other Operations(其他操作)
  6. Nearest points(最近的点)

Nearest points(最近的点)

The nearest_points() function in shapely.ops calculates the nearest points in a pair of geometries.

shapely.ops中的nearest_points()函数计算得到一对几何对象中最近的点。

  • shapely.ops.nearest_points(geom1geom2)

Returns a tuple of the nearest points in the input geometries. The points are returned in the same order as the input geometries.

返回输入几何对象中最近的一组点组成的元组。这些点的返回顺序与输入几何对象的顺序相同。

New in version 1.4.0.

>>> from shapely.ops import nearest_points
>>> triangle = Polygon([(0, 0), (1, 0), (0.5, 1), (0, 0)])
>>> square = Polygon([(0, 2), (1, 2), (1, 3), (0, 3), (0, 2)])
>>> [o.wkt for o in nearest_points(triangle, square)]
['POINT (0.5 1)', 'POINT (0.5 2)']

Note that the nearest points may not be existing vertices in the geometries.

注意,最近的点可能不是几何对象中现有的顶点。

标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here