在 Python / GeoPandas 中组合 shapefile

The*_*ady 1 python gis spatial shapefile geopandas

我有三个相互重叠的多边形 shapefile。让我们称他们为:

  • file_one.shp(多边形名称为 1)
  • file_two.shp(多边形名称为 2)
  • file_three.shp(多边形名称为 3)

我想将它们结合起来并保持这样的值。

在此处输入图片说明

请问如何在Python中实现结果(如图所示)?

谢谢!

小智 5

如果您只想从您提到的文件创建一个 shapefile,您可以尝试以下代码(我假设 shapefiles 具有相同的列)。

import pandas as pd
import geopandas as gpd

gdf1 = gpd.read_file('file_one.shp')
gdf2 = gpd.read_file('file_two.shp')
gdf3 = gpd.read_file('file_three.shp')

gdf = gpd.GeoDataFrame(pd.concat([gdf1, gdf2, gdf3]))
Run Code Online (Sandbox Code Playgroud)