Python GeoPandas – Combining Multiple Shapefiles into One GeoDataFrame Effectively

geopandaspandaspython

I'm trying to vertically concatenate multiple shapefiles that reside in one directory, into one geodataframe. They all have the same table schema and same CRS. I am trying to use the code from this Stack Overflow post, but am getting an error 'WindowsPath' object has no attribute 'split'.

from pathlib import Path   
import geopandas as gpd
import pandas as pd

folder = Path("shp")

gdf = pd.concat([
    gpd.read_file(shp)
    for shp in folder.glob("*.shp") ## error message points to this line ###
]).pipe(gpd.GeoDataFrame)

I'm new to programming and have spent more time than I care to admit trying to figure this one out. I'm open to using alternative Python modules as long as it ends with a geodataframe.

Best Answer

I dug a little deeper into the error message and it mentioned something about . I updated the package and now my script runs. Thanks to @PaulH for his original code I found on Stack Overflow.