{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "266d01e3-75cf-44c0-b648-a5551f3e7c6e", "metadata": {}, "outputs": [], "source": [ "import geopandas as gpd\n", "from pathlib import Path\n", "import pandas as pd\n", "import matplotlib.pyplot as plt\n", "import contextily as ctx\n", "import folium" ] }, { "cell_type": "markdown", "id": "a41d8453-f21e-45c6-b9ba-81b728a7200c", "metadata": {}, "source": [ "## Data processing" ] }, { "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": 5, "id": "bdb98278-1faa-4e1e-9ec5-7efd08a327d1", "metadata": {}, "outputs": [], "source": [ "output_folder = Path('output')\n", "html_folder = Path('html')" ] }, { "cell_type": "code", "execution_count": 11, "id": "60841d8d-81c3-4b8e-ab29-dd4b867e3084", "metadata": {}, "outputs": [], "source": [ "dam_data = gpd.read_file(r\"C:\\Users\\Owner\\OneDrive\\Documents\\Career\\World Bank\\CRP\\data\\GOODD\\GOOD2_dams.shp\")\n", "reservoir_data = gpd.read_file(r\"D:\\World Bank\\CRP\\data\\GRanD\\GRanD_reservoirs_v1_3.shp\")" ] }, { "cell_type": "code", "execution_count": 12, "id": "abd0f218-975d-4f6f-ba0d-93dac4b17cb2", "metadata": {}, "outputs": [ { "data": { "text/plain": [ "Index(['DAM_ID', 'Count_ID', 'Latitud', 'Longitud', 'geometry'], dtype='object')" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "dam_data.columns" ] }, { "cell_type": "code", "execution_count": 13, "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": 14, "id": "0cb6272c-b05c-4d50-a638-f029a91bc862", "metadata": {}, "outputs": [], "source": [ "dams = pd.concat(dams_list)" ] }, { "cell_type": "code", "execution_count": 8, "id": "4ec36a66-1490-482e-9fcb-6ba2fb49306f", "metadata": {}, "outputs": [], "source": [ "dams.to_file(output_folder / f'{city.lower()}_dams.shp')" ] }, { "cell_type": "code", "execution_count": 15, "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": 16, "id": "aefc583c-6804-4304-b890-90dd1af2ad5b", "metadata": {}, "outputs": [], "source": [ "reservoirs = pd.concat(reservoirs_list)" ] }, { "cell_type": "code", "execution_count": 11, "id": "5058abf7-994f-44b2-b1e3-c3effc32dde4", "metadata": {}, "outputs": [], "source": [ "reservoirs.to_file(output_folder / f'{city.lower()}_reservoirs.shp')" ] }, { "cell_type": "markdown", "id": "20a24566-6612-4cd8-8410-11bd49bf772e", "metadata": {}, "source": [ "## Visualization" ] }, { "cell_type": "code", "execution_count": 17, "id": "f0ecf7d0-ee19-4c8b-9413-1bcf3f21b817", "metadata": {}, "outputs": [], "source": [ "dams['DAM_ID'] = dams['DAM_ID'].astype('int').astype('string')" ] }, { "cell_type": "code", "execution_count": 18, "id": "842705c0-3b92-4a01-894a-1fe544873d69", "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | GRAND_ID | \n", "RES_NAME | \n", "DAM_NAME | \n", "ALT_NAME | \n", "RIVER | \n", "ALT_RIVER | \n", "MAIN_BASIN | \n", "SUB_BASIN | \n", "NEAR_CITY | \n", "ALT_CITY | \n", "... | \n", "MULTI_DAMS | \n", "TIMELINE | \n", "COMMENTS | \n", "URL | \n", "QUALITY | \n", "EDITOR | \n", "LONG_DD | \n", "LAT_DD | \n", "POLY_SRC | \n", "geometry | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
3672 | \n", "3676 | \n", "NaN | \n", "Quiminha | \n", "NaN | \n", "Bengo | \n", "NaN | \n", "South West Coast | \n", "Bengo | \n", "Catete | \n", "NaN | \n", "... | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "3: Fair | \n", "McGill-BL | \n", "13.790871 | \n", "-8.963743 | \n", "SWBD | \n", "POLYGON ((14.04531 -8.89675, 14.04585 -8.89781... | \n", "
1 rows × 59 columns
\n", "