Concat_Mutiple_GeoJson_Files
Fri Sep 29 2023 13:40:14 GMT+0000 (Coordinated Universal Time)
Saved by
@leandrorbc
#python
import os
import glob
import geopandas as gpd
import pandas as pd
import re
json_dir_name = "/Users/agroclimate/Documents/PriceFrobes/Uruguay/Poligonos/GeoJson/2023/"
json_pattern = os.path.join(json_dir_name,'*.geojson')
file_list = glob.glob(json_pattern)
collection = gpd.GeoDataFrame([])
for file in file_list:
print(file)
newGpd = gpd.read_file(file)
newGpd['NAME'] = re.sub(r"[^a-zA-Z0-9]","_",os.path.basename(file)[:-8])
collection = pd.concat([collection,newGpd])
collection = collection.loc[collection.geometry.geom_type=='Polygon']
collection.to_file('/Users/agroclimate/Documents/PriceFrobes/Uruguay/Poligonos/GeoJson/Col_2023_name.shp')
content_copyCOPY
Comments