【发布时间】:2021-08-02 19:36:24
【问题描述】:
我试图找到两个 3d 多边形的交点,我有 XYZ 坐标。
我搜索了几个小时,但没有找到满足我要求的好解决方案。 作为最终结果,我想要像 Shapely 这样的东西,我可以在其中给出两个多边形的 XYZ 坐标,并得到交叉点的坐标。
# This code is just for example returns an error because Shapely only works with XY
from shapely.wkt import loads
poly = loads('POLYGON ((0 0 0, 100 0 100, 100 100 100, 0 100 0, 0 0 0))')
poly_horizontal_line = loads('POLYGON ((-50 50 -50, -50 50 150, 150 50 150, 150 50 -50, -50 50 -50))')
intersection = poly_horizontal_line.exterior.intersection(poly)
if intersection.is_empty:
print("shapes don't intersect")
elif intersection.geom_type.startswith('Multi') or intersection.geom_type == GeometryCollection':
for shp in intersection:
print(shp)
else:
print(intersection)
有没有人可以提供建议或替代库来实现这一目标? 在此先感谢:)
【问题讨论】:
-
你为什么想要一个不同的库,这不符合你的目的吗?
-
Shapely 仅适用于 2 轴 XY,我需要 XYZ..
-
this 图书馆对你有帮助吗?
-
嗨,我遇到了这个库,但我认为它不能解决我的问题。我试了一下,终于成功了,谢谢!我也在发布我的解决方案。
标签: python intersection shapely