计算重叠区域

问题描述 投票:0回答:1

我正在遵循示例here,并成功创建了凸包。但是我有一个问题,如何在下图中计算每个凸包之间的共享区域:enter image description here

谢谢!

area geopandas convex-hull
1个回答
0
投票

这里是获得曼哈顿和布朗克斯交叉点的示例。如果要合并自治市镇,可以在.overlay()之前使用pd.concat()。

import geopandas as gpd
nybb_path = gpd.datasets.get_path('nybb')

boros = gpd.read_file(nybb_path)
boros.set_index('BoroCode', inplace=True)
boros.sort_index(inplace=True)

boros['geometry'] = boros['geometry'].convex_hull

print(boros)
    BoroName    Shape_Leng  Shape_Area  geometry
BoroCode                
1   Manhattan   359299.096471   6.364715e+08    POLYGON ((977855.445 188082.322, 971830.134 19...
2   Bronx   464392.991824   1.186925e+09    POLYGON ((1017949.978 225426.885, 1015563.562 ...
3   Brooklyn    741080.523166   1.937479e+09    POLYGON ((988872.821 146772.032, 983670.606 14...
4   Queens  896344.047763   3.045213e+09    POLYGON ((1000721.532 136681.776, 994611.996 2...
5   Staten Island   330470.010332   1.623820e+09    POLYGON ((915517.688 120121.881, 915467.035 12...

manhattan_gdf = boros.iloc[0:1, :]
bronx_gdf = boros.iloc[1:2, :]

manhattan_bronx_intersecetion_polygon = gpd.overlay(manhattan_gdf, bronx_gdf, 
how='intersection')

#SPCS83 New York Long Island zone (US Survey feet)
print(manhattan_bronx_intersecetion_polygon.geometry[0].area)
164559574.89341027

ax = manhattan_bronx_intersecetion_polygon.plot(figsize=(6,6))
boros.plot(ax=ax, facecolor='none', edgecolor='k');

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.