如何从 scipy Delaunay 三角剖分的输出中 select 仅在特定体积(或总线长)下单纯形化?

How to select from the output of scipy Delaunay triangulation only simplices under certain volume (or under total line length)?

我在一组点上使用 Delaunay 三角剖分,试图以规则模式隔离点簇。

我第一次使用 qhull.Delaunay 对象,请耐心等待...

from scipy.spatial import Delaunay
tri = Delaunay(array)

目前看起来像:

而且我发现我可以 print (tri.simplices) 获取列表。我只想隔离明显簇中的那些,我想这可以通过删除线长度或体积超过某个阈值的那些来完成,但我不确定如何操纵结果来做到这一点?

找到答案 - 发布以防对其他人有用。

Delaunay 输出为您提供每个点的坐标列表,以及每个三角形由三个点组成的嵌套列表。

要访问它们的区域,首先将其转换为形状多边形的列表,然后你的多边形就是你的牡蛎。

from shapely.geometry.polygon import Polygon

coord_groups = [tri.points[x] for x in tri.simplices]
polygons = [Polygon(x) for x in coord_groups]

#area of the first polygon
polygons[0].area