#!/usr/bin/env python # coding: utf-8 # In[13]: import geopandas as gpd from pathlib import Path import pandas as pd # In[2]: city = 'Luanda' # In[3]: # read catchment AOI aoi = gpd.read_file('AOI/luanda_catchment_level4.shp').to_crs(epsg = 4326) # In[6]: 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") # In[15]: dam_data.columns # In[21]: # 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'])]) # In[24]: dams = pd.concat(dams_list) # In[28]: dams.to_file(output_folder / f'{city.lower()}_dams.shp') # In[25]: # 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'])]) # In[27]: reservoirs = pd.concat(reservoirs_list) # In[29]: reservoirs.to_file(output_folder / f'{city.lower()}_reservoirs.shp')