I am reading multiple shapefiles (around 14) using the function below:
def import_shapes_list(path_to_data:str,shapes_folder:str,crs:str) ->gpd.GeoDataFrame:
"""
"""
files = glob.iglob(path_to_data+shapes_folder+'*.shp')
gdfs = [gpd.read_file(file).to_crs(crs) for file in files]
for gdf in gdfs:
gdf.columns = map(str.lower, gdf.columns)
geomap = gpd.GeoDataFrame( pd.concat( gdfs, ignore_index=True) )
return geomap
geomap = import_shapes_list(path_to_data=xxx,shapes_folder=xxx,crs='EPSG:4326')
The error A LinearRing must have at least 3 coordinate tuples
tells me that a polygon must have at least three points.
I tried to fix this by introducing try and except
try:
# xxx
except ValueError:
# xxx
As follows:
try:
gdfs = [gpd.read_file(file).to_crs(crs) for file in files]
except:
print(e)
return gdfs
but I am still getting the same error. I also have no idea where that polygon with error is as I have 14 shapefiles.
Any idea on how to tackle this?