import geopandas as gpd
from pathlib import Path
import pandas as pd
city = 'Luanda'
# read catchment AOI
aoi = gpd.read_file('AOI/luanda_catchment_level4.shp').to_crs(epsg = 4326)
output_folder = Path('output')
dam_data = gpd.read_file(r"C:\Users\Owner\Documents\Career\World Bank\CRP\data\GOODD\GOOD2_dams.shp")
reservoir_data = gpd.read_file(r"C:\Users\Owner\Documents\Career\World Bank\CRP\data\GRanD\GRanD_reservoirs_v1_3.shp")
dam_data.columns
Index(['DAM_ID', 'Count_ID', 'Latitud', 'Longitud', 'geometry'], dtype='object')
# filter for dams in AOI
dams_list = []
for i in range(len(aoi)):
dams_list.append(dam_data.loc[dam_data.within(aoi.loc[i, 'geometry'])])
dams = pd.concat(dams_list)
dams.to_file(output_folder / f'{city.lower()}_dams.shp')
# filter for reservoirs in AOI
reservoirs_list = []
for i in range(len(aoi)):
reservoirs_list.append(reservoir_data.loc[reservoir_data.within(aoi.loc[i, 'geometry'])])
reservoirs = pd.concat(reservoirs_list)
reservoirs.to_file(output_folder / f'{city.lower()}_reservoirs.shp')