简体   繁体   中英

Geopandas overlay intersection doesnt work as expected

I wanted to calculate store coverage in a city with Geopandas overlay function. 'store' data has 2 store entries with polygon data of store area and 'area' data has 1 area entry with polygon data of the city area.

Now, I expected to have the only 2-row output of the store coverage in the city but I am getting 3 rows as the store area overlap each other and it is included in the output. is there any way to NOT consider those store overlap and only get the result of 'area' intersect?

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

That indeed seems incorrect (at least a QGIS overlay operation produces 2 features in the result). I opened an issue for it: https://github.com/geopandas/geopandas/issues/666

As a temporary workaround, you can use the definition of spatial_overlay that is defined here: https://github.com/geopandas/geopandas/pull/338#issuecomment-290303715 (that will used as a basis to fix it in geopandas itself, and for now you can copy paste the function if you want)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM