首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >几何图形集的最小包络

几何图形集的最小包络
EN

Stack Overflow用户
提问于 2022-04-14 11:21:17
回答 1查看 325关注 0票数 0

为了能够在地理数据集中的一组几何图形上进行操作,我需要能够确定物体是否在集合的外部“边缘”上。几何学的集合如下:

要做到这一点,我想要创建一个多边形,它与几何对象集合的外界完全匹配。我首先想到的是使用这个集合的凸包:

代码语言:javascript
运行
复制
convex_hull = Sectioned_geostore_obstacles_geometry.unary_union.convex_hull
convex_hull = geopandas.GeoDataFrame({'geometry': convex_hull, 'convex_hull':[1]})

ax = Sectioned_geostore_obstacles_geometry['Gondola'].plot(color='red')
convex_hull.plot(ax=ax, color='green', alpha=0.5)

这会导致

但这是不完全正确的,因为我要寻找的不是凸的。第二个想法是使用信封:

代码语言:javascript
运行
复制
envelope = Sectioned_geostore_obstacles_geometry.unary_union.envelope
envelope = geopandas.GeoDataFrame({'geometry': envelope, 'convex_hull':[1]})

ax = Sectioned_geostore_obstacles_geometry['Gondola'].plot(color='red')
envelope.plot(ax=ax, color='green', alpha=0.5)

这就是

再说一次,不是这样的。另一种尝试是使用shapely中的cascade_union功能:

代码语言:javascript
运行
复制
from shapely.ops import cascaded_union
polygons = list(Sectioned_geostore_obstacles_geometry.Gondola)
boundary = gpd.GeoSeries(cascaded_union(polygons))

即:

但是,这也不是它,因为它返回一个多多边形,而不是最小的发展多边形。基本上,我需要信封收缩,以跟随一组物体的轮廓。

任何见解都将不胜感激。

为了测试这一点,我添加了以下示例数据:

代码语言:javascript
运行
复制
test_df =  geopandas.GeoSeries([Polygon([(0,0), (2,0), (2,2), (0,2)]),
                              Polygon([(2,2), (4,2), (4,4), (2,4)])])
test_df = geopandas.GeoDataFrame({'geometry': test_df, 'df1':[1,2]})

convex_hull = test_df.unary_union.convex_hull
convex_hull = geopandas.GeoDataFrame({'geometry': convex_hull, 'convex_hull':[1]})

ax1 = test_df['geometry'].plot(color='red')
convex_hull.plot(ax=ax1, color='green', alpha=0.5)

envelope = test_df.unary_union.envelope
envelope = geopandas.GeoDataFrame({'geometry': envelope, 'convex_hull':[1]})

ax2 = test_df['geometry'].plot(color='red')
envelope.plot(ax=ax2, color='green', alpha=0.5)

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-04-14 14:01:44

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71870815

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档