答案 0 :(得分:1)
这取决于您希望如何处理附加到这些多边形上的数据。如果您不关心它们并且只对几何感兴趣,那么一种选择是溶解整个 GeoDataFrame,然后将其分解。
combined_polygons = gdf.dissolve().explode()
然而,这可能不是最有效的解决方案。最好的方法是确定邻接组件并根据这些组件进行分解。你可以很容易地用 libpysal
做到这一点。
import libpysal
# create spatial weights matrix
W = libpysal.weights.Queen.from_dataframe(gdf)
# get component labels
components = W.component_labels
combined_polygons = earth.dissolve(by=components)
后者将允许您在 aggfunc
中指定 dissolve
以管理其他属性。