Shapely 2.0.0 中文文档

  1. 主页
  2. 文档
  3. Shapely 2.0.0 中文文档
  4. User Manual
  5. Other Operations(其他操作)
  6. Voronoi Diagram(泰森多边形)

Voronoi Diagram(泰森多边形)

The voronoi_diagram() function in shapely.ops constructs a Voronoi diagram from a collection points, or the vertices of any geometry.

shapely.ops中的voronoi_diagram()函数通过一个点集或任何几何对象的顶点构建一个泰森多边形。

(Source codepnghires.pngpdf)

  • shapely.ops.voronoi_diagram(geomenvelope=Nonetolerance=0.0edges=False)

Constructs a Voronoi diagram from the vertices of the input geometry.

通过输入几何对象的顶点构建一个泰森多边形。

The source may be any geometry type. All vertices of the geometry will be used as the input points to the diagram.

可以是任何几何对象类型。该几何对象的所有顶点都将被用作图表的输入点。

The envelope keyword argument provides an envelope to use to clip the resulting diagram. If None, it will be calculated automatically. The diagram will be clipped to the larger of the provided envelope or an envelope surrounding the sites.

envelope关键字参数提供了一个用于裁剪结果图的外包矩形。如果没有,它将被自动计算。图表将被裁剪到所提供的包络矩形或围绕这些点的包络矩形中较大的一个。

The tolerance keyword argument sets the snapping tolerance used to improve the robustness of the computation. A tolerance of 0.0 specifies that no snapping will take place. The tolerance argument can be finicky and is known to cause the algorithm to fail in several cases. If you’re using tolerance and getting a failure, try removing it. The test cases in tests/test_voronoi_diagram.py show more details.

容差参数的设置用于提高计算稳健性。容差参数为0.0表示不进行捕获。容差参数可能很不稳定,已知在一些情况下会导致算法失败。如果你正在使用容差参数并计算失败,试着去掉它。tests/test_voronoi_diagram.py中的测试案例显示了更多细节。

If the edges keyword argument is False a list of Polygon`s will be returned. Otherwise a list of `LineString edges is returned.

如果edges参数为False,将返回Polygon列表。否则将返回一个LineString边界的列表。

>>> from shapely.ops import voronoi_diagram
>>> points = MultiPoint([(0, 0), (1, 1), (0, 2), (2, 2), (3, 1), (1, 0)])
>>> regions = voronoi_diagram(points)
>>> list(regions.geoms)
[<POLYGON ((2 1, 2 0.5, 0.5 0.5, 0 1, 1 2, 2 1))>,
 <POLYGON ((6 -3, 3.75 -3, 2 0.5, 2 1, 6 5, 6 -3))>,
 <POLYGON ((-3 -3, -3 1, 0 1, 0.5 0.5, 0.5 -3, -3 -3))>,
 <POLYGON ((0.5 -3, 0.5 0.5, 2 0.5, 3.75 -3, 0.5 -3))>,
 <POLYGON ((-3 5, 1 5, 1 2, 0 1, -3 1, -3 5))>,
 <POLYGON ((6 5, 2 1, 1 2, 1 5, 6 5))>]
标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here