Skip to content

Commit

Permalink
Revise hydrobasin files to merge
Browse files Browse the repository at this point in the history
  • Loading branch information
davide-f committed Nov 29, 2023
1 parent 3fce893 commit 9052d79
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions scripts/retrieve_databundle_light.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,15 +736,15 @@ def merge_hydrobasins_shape(config_hydrobasin, hydrobasins_level):
basins_path = config_hydrobasin["destination"]
output_fl = config_hydrobasin["output"][0]

mask_file = os.path.join(
basins_path, "hybas_??_lev{:02d}_v1c.shp".format(int(hydrobasins_level))
)
files_to_merge = glob.glob(mask_file)
files_to_merge = [
"hybas_{0:s}_lev{1:02d}_v1c.shp".format(suffix, hydrobasins_level)
for suffix in config_hydrobasin["urls"]["hydrobasins"]["suffixes"]
]

gpdf_list = [None] * len(files_to_merge)
logger.info("Reading hydrobasins files \n\r")
for i in tqdm(range(0, len(files_to_merge))):
gpdf_list[i] = gpd.read_file(files_to_merge[i])
for i, f_name in tqdm(enumerate(files_to_merge)):
gpdf_list[i] = gpd.read_file(os.path.join(basins_path, f_name))
fl_merged = gpd.GeoDataFrame(pd.concat(gpdf_list)).drop_duplicates(
subset="HYBAS_ID", ignore_index=True
)
Expand Down

0 comments on commit 9052d79

Please sign in to comment.