Geopandas 叠加交叉点无法按预期工作

Geopandas overlay intersection doesnt work as expected

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

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

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 个特征)。我为此开了一个问题:https://github.com/geopandas/geopandas/issues/666

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