{ "cells": [ { "cell_type": "code", "execution_count": 13, "id": "266d01e3-75cf-44c0-b648-a5551f3e7c6e", "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "from pathlib import Path\n", "import pandas as pd" ] }, { "cell_type": "code", "execution_count": 2, "id": "a24db3f2-c414-4664-ab23-c30a77547be2", "metadata": {}, "outputs": [], "source": [ "city = 'Luanda'" ] }, { "cell_type": "code", "execution_count": 3, "id": "53e8bce0-a7c8-406e-bccb-98451d20c9b8", "metadata": {}, "outputs": [], "source": [ "# read catchment AOI\n", "aoi = gpd.read_file('AOI/luanda_catchment_level4.shp').to_crs(epsg = 4326)" ] }, { "cell_type": "code", "execution_count": 6, "id": "bdb98278-1faa-4e1e-9ec5-7efd08a327d1", "metadata": {}, "outputs": [], "source": [ "output_folder = Path('output')\n", "dam_data = gpd.read_file(r\"C:\\Users\\Owner\\Documents\\Career\\World Bank\\CRP\\data\\GOODD\\GOOD2_dams.shp\")\n", "reservoir_data = gpd.read_file(r\"C:\\Users\\Owner\\Documents\\Career\\World Bank\\CRP\\data\\GRanD\\GRanD_reservoirs_v1_3.shp\")" ] }, { "cell_type": "code", "execution_count": 15, "id": "abd0f218-975d-4f6f-ba0d-93dac4b17cb2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['DAM_ID', 'Count_ID', 'Latitud', 'Longitud', 'geometry'], dtype='object')" ] }, "execution_count": 15, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dam_data.columns" ] }, { "cell_type": "code", "execution_count": 21, "id": "ddecea9a-2ec4-4aba-8366-20819bb46e28", "metadata": {}, "outputs": [], "source": [ "# filter for dams in AOI\n", "dams_list = []\n", "\n", "for i in range(len(aoi)):\n", " dams_list.append(dam_data.loc[dam_data.within(aoi.loc[i, 'geometry'])])" ] }, { "cell_type": "code", "execution_count": 24, "id": "0cb6272c-b05c-4d50-a638-f029a91bc862", "metadata": {}, "outputs": [], "source": [ "dams = pd.concat(dams_list)" ] }, { "cell_type": "code", "execution_count": 28, "id": "4ec36a66-1490-482e-9fcb-6ba2fb49306f", "metadata": {}, "outputs": [], "source": [ "dams.to_file(output_folder / f'{city.lower()}_dams.shp')" ] }, { "cell_type": "code", "execution_count": 25, "id": "c3c3b70a-6b7c-412a-b703-f57a232298aa", "metadata": {}, "outputs": [], "source": [ "# filter for reservoirs in AOI\n", "reservoirs_list = []\n", "\n", "for i in range(len(aoi)):\n", " reservoirs_list.append(reservoir_data.loc[reservoir_data.within(aoi.loc[i, 'geometry'])])" ] }, { "cell_type": "code", "execution_count": 27, "id": "aefc583c-6804-4304-b890-90dd1af2ad5b", "metadata": {}, "outputs": [], "source": [ "reservoirs = pd.concat(reservoirs_list)" ] }, { "cell_type": "code", "execution_count": 29, "id": "5058abf7-994f-44b2-b1e3-c3effc32dde4", "metadata": {}, "outputs": [], "source": [ "reservoirs.to_file(output_folder / f'{city.lower()}_reservoirs.shp')" ] } ], "metadata": { "kernelspec": { "display_name": "crp", "language": "python", "name": "crp" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.10.12" } }, "nbformat": 4, "nbformat_minor": 5 }