确定地geopandas点是否在带有孔的通用多边形中
此线程在这里提供了一个解决方案,说明如何确定geopandas
> point
在实体polygon
中。
对于用孔确定Polygon
的通用解决方案,即MultipolyGon
。
例如,使用foo
下面:
from shapely.geometry import Point, Polygon
import geopandas
polys = geopandas.GeoSeries({
'foo': Polygon([(5, 5), (5, 13), (13, 13), (13, 5)],
[[(7, 7), (7, 11), (11, 11), (11, 7)]]),
'bar': Polygon([(10, 10), (10, 15), (15, 15), (15, 10)]),
})
_pnts = [Point(3, 3), Point(8, 8), Point(11, 11)]
pnts = geopandas.GeoDataFrame(geometry=_pnts, index=['A', 'B', 'C'])
This thread here gave a solution of how to determine if a geopandas
POINT
is in a solid POLYGON
.
What would be a generic solution to determine this for a POLYGON
with holes, i.e. MULTIPOLYGON
.
For e.g., using foo
below:
from shapely.geometry import Point, Polygon
import geopandas
polys = geopandas.GeoSeries({
'foo': Polygon([(5, 5), (5, 13), (13, 13), (13, 5)],
[[(7, 7), (7, 11), (11, 11), (11, 7)]]),
'bar': Polygon([(10, 10), (10, 15), (15, 15), (15, 10)]),
})
_pnts = [Point(3, 3), Point(8, 8), Point(11, 11)]
pnts = geopandas.GeoDataFrame(geometry=_pnts, index=['A', 'B', 'C'])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
严格来说,您提供的样品是多边形。几何包含一个孔。
测试非常简单,只需使用 convex_hull 即可。下面的代码进行了这两个测试。
Strictly the sample you have provided are polygons. Geometry contains a hole.
It's pretty straight forward to test, just use convex_hull. Code below does both tests.