【问题标题】:Geopandas overlay intersection doesnt work as expectedGeopandas 叠加交叉点无法按预期工作
【发布时间】:2018-02-07 22:36:17
【问题描述】:

我想用 Geopandas 叠加功能计算一个城市的商店覆盖率。 “商店”数据有 2 个商店条目,其中包含商店区域的多边形数据,“区域”数据有 1 个区域条目,其中包含城市区域的多边形数据。

现在,我希望只有 2 行输出的商店覆盖城市,但我得到 3 行,因为商店区域相互重叠并且包含在输出中。有没有办法不考虑那些商店重叠而只得到“区域”相交的结果?

import geopandas as gpd

area = gpd.read_file(out_area)
store = gpd.read_file(out_store)
inter = gpd.overlay(st_store, st_area, how = 'intersection')
print(len(store), len(inter))
# Result would be 2, 3 but expected to have 2, 2

【问题讨论】:

  • 这确实看起来不正确(至少 QGIS 覆盖操作会在结果中产生 2 个特征。我为此打开了一个问题:github.com/geopandas/geopandas/issues/666
  • 非常感谢您开票,期待解决。

标签: python pandas geopandas


【解决方案1】:

这确实看起来不正确(至少 QGIS 覆盖操作会在结果中产生 2 个特征)。我为它开了一个问题:https://github.com/geopandas/geopandas/issues/666

作为一种临时解决方法,您可以使用此处定义的spatial_overlay 的定义:https://github.com/geopandas/geopandas/pull/338#issuecomment-290303715(这将用作在 geopandas 本身中修复它的基础,现在您可以复制粘贴该功能,如果您想要)

【讨论】:

  • 非常感谢您的及时支持,这确实解决了问题
猜你喜欢
  • 2023-03-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-11-27
  • 1970-01-01
  • 1970-01-01
  • 2020-09-10
  • 2019-09-24
相关资源
最近更新 更多