如何在整体多角形中找到包含多边形的多边形

发布于 2025-02-11 18:53:30 字数 346 浏览 2 评论 0原文

在Shapely中,一个多角形由几个不相交的多边形(除了单点交叉路口除外)。如果我有一个Moulderygon polys和一个pt,那么我可以测试限制

polys.contains(pt)

true,以防该点至少在多边形之一。我认为通过使用一些R-Tree在内部有效地工作。但是,实际上,我很感兴趣,对多角形中的多边形的哪个包含了点。我想知道,是否有一个技巧可以识别它而不通过多边形列表进行测试(即polys.geoms)?

任何提示都将受到赞赏 - 谢谢!!

In shapely, a MultiPolygon is made of several disjoint Polygons (except one-point intersections). If I have a MultiPolygon polys and a Point pt, then I can test for containment by

polys.contains(pt)

which gives True in case the point is in at least one of the polygons. I assume this is working efficiently on the inside by using some R-Tree. However, actually, I am interested, in which of the Polygons in the MultiPolygon the Point is contained. I wonder, whether there is a trick to identify it without testing through the list of polygons (i.e., polys.geoms)?

Any hint is appreciated - thanks already!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

带刺的爱情 2025-02-18 18:53:30

您可以随时使用语法

for poly in polys.geoms:
    if poly.contains(pt):
        print(poly)

You could always use the syntax

for poly in polys.geoms:
    if poly.contains(pt):
        print(poly)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文