Concat multiple shapefiles via geopandas

后端 未结 2 711
悲&欢浪女
悲&欢浪女 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:39

    I can't test this since I don't have your data, but you want something like this (assuming python 3):

    from pathlib import Path
    import pandas
    import geopandas
    
    folder = Path("/Users/m3105/Downloads/area")
    shapefiles = folder.glob("tl_2015_*_arealm.shp")
    gdf = pandas.concat([
        geopandas.read_file(shp)
        for shp in shapefiles
    ]).pipe(geopandas.GeoDataFrame)
    gdf.to_file(folder / 'compiled.shp')
    

提交回复
热议问题