Concat multiple shapefiles via geopandas

后端 未结 2 712
悲&欢浪女
悲&欢浪女 2021-02-08 23:04

I\'m trying to combine multiple shapefiles by implementing the follwing:

import geopandas as gpd
import pandas as pd

for i in range(10,56):
    interesting_file         


        
2条回答
  •  太阳男子
    2021-02-08 23:31

    If using pandas.concat like the answer of @Paul H, some geographical imformation such as coordinate reference system(crs) does not get preserved by default. But it worked when using the way like below:

    import os
    import geopandas as gpd
    
    file = os.listdir("Your folder")
    path = [os.path.join("Your folder", i) for i in file if ".shp" in i]
    
    gdf = gpd.GeoDataFrame(pd.concat([gpd.read_file(i) for i in path], 
                            ignore_index=True), crs=gpd.read_file(path[0]).crs)
    

    In this way, the geodataframe will have CRS as your need

提交回复
热议问题