Skip to content

Commit 6b9cf0f

Browse files
committed
Add bivariate notebook and F3 combine utility
1 parent 4069d9a commit 6b9cf0f

File tree

4 files changed

+315
-112
lines changed

4 files changed

+315
-112
lines changed

tools/code/F3/F3_combine_types.ipynb

Lines changed: 157 additions & 109 deletions
Large diffs are not rendered by default.

tools/code/GUI.ipynb

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
" <td>\n",
1818
" <h2 style=\"text-align: center;\">\n",
1919
" <a href=\"GUI_F3.ipynb\" style=\"text-decoration: none;\">\n",
20-
" <b>FLOODS</b> (Fluvial, Pluvial, Coastal)\n",
20+
" <b>Floods</b> (Fluvial, Pluvial, Coastal)\n",
2121
" </a>\n",
2222
" </h2>\n",
2323
" <p>\n",
@@ -26,7 +26,7 @@
2626
" <p>\n",
2727
" The tool expects Fathom 3 data as country-wide RP layers. To merge downloaded tiles, use the \n",
2828
" <a href=\"F3/F3_preprocessing.ipynb\" style=\"text-decoration: none;\">\n",
29-
" <b>Fathom 3 pre-processing tool</b>.\n",
29+
" <b>Fathom 3 pre-processing tool</b></a>.<br>You can also combine the three flood types into one using MAX water depth criteria with the <a href=\"F3/F3_combine_types.ipynb\" style=\"text-decoration: none;\"><b>Flood types combination tool</b>.\n",
3030
" </a>\n",
3131
" </p>\n",
3232
" </td>\n",
@@ -38,7 +38,7 @@
3838
" <td>\n",
3939
" <h2 style=\"text-align: center\">\n",
4040
" <a href=\"GUI_TC.ipynb\" style=\"text-decoration: none;\">\n",
41-
" <b>TROPICAL CYCLONES</b> (Strong wind)\n",
41+
" <b>Tropical Cyclones</b> (Strong wind)\n",
4242
" </a>\n",
4343
" </h2>\n",
4444
" <p>\n",
@@ -113,6 +113,26 @@
113113
" </tr>\n",
114114
"</table>\n",
115115
"\n",
116+
"<h3 style=\"text-align: center\">Bi-variate maps</h3>\n",
117+
"\n",
118+
"<table width=\"90%\">\n",
119+
" <tr>\n",
120+
" <td width=\"10%\">\n",
121+
" <img src=\"icons/bivariate.png\" width=\"80\" height=\"80\" alt=\"Climate indices icon\">\n",
122+
" </td>\n",
123+
" <td>\n",
124+
" <h2 style=\"text-align: center;\">\n",
125+
" <a href=\"GUI_bivariate-maps.ipynb\" style=\"text-decoration: none;\">\n",
126+
" <b>Risk-Poverty Bivariate Maps</b>\n",
127+
" </a>\n",
128+
" </h2>\n",
129+
" <p>\n",
130+
" Generate bivariate maps based on hazard or risk ranking and wealth (or poverty) quantiles.\n",
131+
" </p>\n",
132+
" </td>\n",
133+
" </tr>\n",
134+
"</table>\n",
135+
"\n",
116136
"<p style=\"text-align: right; margin-top: 3em;\"><em>Developed by M. Amadio (mamadio@worldbank.org)</em></p>"
117137
]
118138
},
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "6ce9d524-db59-44c6-9122-c84a2e3594a1",
6+
"metadata": {},
7+
"source": [
8+
"# **RDL - CCDR analytics interface**\n",
9+
"\n",
10+
"## Bivariate Risk-Poverty Mapping Tool\n",
11+
"\n",
12+
"<p>This tool creates bivariate maps combining hazard risk analytics with relative wealth index data.</p>\n",
13+
"<p>Input data should be a GeoPackage file with administrative boundaries containing fields for: Unit ID, Unit NAME, Unit POP, RWI, and hazard score (e.g., FL EAI).</p>\n",
14+
"<p>The tool calculates population-weighted relative wealth index and combines it with hazard data into a bivariate choropleth map.</p>\n",
15+
"\n",
16+
"### Cell > Run all or CTRL + Enter"
17+
]
18+
},
19+
{
20+
"cell_type": "code",
21+
"execution_count": 1,
22+
"id": "86fc5cc8-22d6-4dfd-816f-739ed9738273",
23+
"metadata": {},
24+
"outputs": [
25+
{
26+
"data": {
27+
"application/vnd.jupyter.widget-view+json": {
28+
"model_id": "ecae8f2f424045399c6a067d866f6db9",
29+
"version_major": 2,
30+
"version_minor": 0
31+
},
32+
"text/plain": [
33+
"VBox(children=(HTML(value='\\n <div style=\\'\\n background: linear-gradient(to bottom, #003366, transp…"
34+
]
35+
},
36+
"metadata": {},
37+
"output_type": "display_data"
38+
},
39+
{
40+
"data": {
41+
"text/html": [
42+
"\n",
43+
" <script>\n",
44+
" document.querySelector('.file-path-text-3148162213648').onmouseover = function() {\n",
45+
" document.querySelector('.info-box textarea').value = 'Enter the path to your GeoPackage file containing boundary data with wealth and hazard information.';\n",
46+
" };\n",
47+
" document.querySelector('.layer-selector-3148162608784').onmouseover = function() {\n",
48+
" document.querySelector('.info-box textarea').value = 'Select the layer from the GeoPackage file to analyze. This is only applicable if your file contains multiple layers.';\n",
49+
" };\n",
50+
" document.querySelector('.id-field-selector-3148162605088').onmouseover = function() {\n",
51+
" document.querySelector('.info-box textarea').value = 'Select the field that contains unique identifiers for each boundary feature.';\n",
52+
" };\n",
53+
" document.querySelector('.name-field-selector-3148162599376').onmouseover = function() {\n",
54+
" document.querySelector('.info-box textarea').value = 'Select the field that contains the name or label for each boundary feature.';\n",
55+
" };\n",
56+
" document.querySelector('.population-field-selector-3148162603984').onmouseover = function() {\n",
57+
" document.querySelector('.info-box textarea').value = 'Select the field that contains population data. This is used to calculate population-weighted wealth index.';\n",
58+
" };\n",
59+
" document.querySelector('.wealth-field-selector-3148162219072').onmouseover = function() {\n",
60+
" document.querySelector('.info-box textarea').value = 'Select the field that contains relative wealth index (RWI) or other wealth indicator data.';\n",
61+
" };\n",
62+
" document.querySelector('.hazard-field-selector-3148162606960').onmouseover = function() {\n",
63+
" document.querySelector('.info-box textarea').value = 'Select the field that contains hazard risk data (e.g., flood risk index, expected annual impact).';\n",
64+
" };\n",
65+
" document.querySelector('.quantiles-selector-3148162601536').onmouseover = function() {\n",
66+
" document.querySelector('.info-box textarea').value = 'Select the number of quantiles to use for classifying both wealth and hazard data.\\n\\n3×3 creates a 9-cell bivariate map (tertiles)\\n4×4 creates a 16-cell bivariate map (quartiles)\\n5×5 creates a 25-cell bivariate map (quintiles)';\n",
67+
" };\n",
68+
" document.querySelector('.bivariate-palette-selector-3148162597456').onmouseover = function() {\n",
69+
" document.querySelector('.info-box textarea').value = 'Select the bivariate color palette to use for the map. Each palette is designed to show both poverty and hazard risk with appropriate color relationships.';\n",
70+
" };\n",
71+
" </script>\n",
72+
" "
73+
],
74+
"text/plain": [
75+
"<IPython.core.display.HTML object>"
76+
]
77+
},
78+
"metadata": {},
79+
"output_type": "display_data"
80+
}
81+
],
82+
"source": [
83+
"%matplotlib inline\n",
84+
"from gui_bivariate_utils import initialize_tool\n",
85+
"initialize_tool()"
86+
]
87+
},
88+
{
89+
"cell_type": "markdown",
90+
"id": "8f194706-429e-440a-a09d-26aaa17077be",
91+
"metadata": {},
92+
"source": [
93+
"### Methodology\n",
94+
"\n",
95+
"#### Population-Weighted Relative Wealth Index\n",
96+
"The Relative Wealth Index (RWI) is weighted by population to provide a more accurate representation of wealth distribution across administrative areas:\n",
97+
"\n",
98+
"1. Calculate the population-weighted RWI for each area: `RWI × Population density`\n",
99+
"2. Sum these values across all areas\n",
100+
"3. Divide each area's weighted value by the total sum\n",
101+
"4. Normalize the resulting values to create w_RWIxPOP\n",
102+
"\n",
103+
"#### Bivariate Mapping\n",
104+
"The bivariate map combines two variables (wealth and hazard risk) into a single visualization:\n",
105+
"\n",
106+
"1. Both variables are classified into the selected number of quantiles\n",
107+
"2. The two classifications are combined into a matrix where each cell represents a specific combination\n",
108+
"3. Colors are assigned based on the selected color palettes, creating a 3×3, 4×4 or 5x5 grid of colors\n",
109+
"\n",
110+
"This approach allows for visualizing the relationship between poverty and hazard risk in a single map, highlighting areas with different combinations of wealth and vulnerability."
111+
]
112+
}
113+
],
114+
"metadata": {
115+
"kernelspec": {
116+
"display_name": "Python 3 (ipykernel)",
117+
"language": "python",
118+
"name": "python3"
119+
},
120+
"language_info": {
121+
"codemirror_mode": {
122+
"name": "ipython",
123+
"version": 3
124+
},
125+
"file_extension": ".py",
126+
"mimetype": "text/x-python",
127+
"name": "python",
128+
"nbconvert_exporter": "python",
129+
"pygments_lexer": "ipython3",
130+
"version": "3.10.14"
131+
}
132+
},
133+
"nbformat": 4,
134+
"nbformat_minor": 5
135+
}

tools/code/icons/bivariate.png

12.1 KB
Loading

0 commit comments

Comments
 (0)