我想用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
答案 0 :(得分:0)
这确实看起来不正确(至少QGIS叠加操作会在结果中产生2个特征)。我为它开了一个问题:https://github.com/geopandas/geopandas/issues/666
作为一种临时解决方法,您可以使用此处定义的spatial_overlay
定义:https://github.com/geopandas/geopandas/pull/338#issuecomment-290303715(将用作在geopandas中修复它的基础,现在您可以复制粘贴如果你想要的功能)