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')
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter