Spaces:
Running
Running
Upload 25 files
Browse files
README.md
CHANGED
@@ -45,10 +45,11 @@ All files that are used to do Exploratory Data Analysis is stored in this [Googl
|
|
45 |
```bash
|
46 |
conda install -c conda-forge gdal
|
47 |
```
|
|
|
48 |
```bash
|
49 |
pip install -r requirements.txt
|
50 |
```
|
51 |
-
- If there are no errors, you should be able to run the app smoothly
|
52 |
- Remember to run everything inside your virtual environment.
|
53 |
|
54 |
### Running the Application
|
|
|
45 |
```bash
|
46 |
conda install -c conda-forge gdal
|
47 |
```
|
48 |
+
- OPTIONAL: Uncomment Lines 3 - 7 in ```requirements.txt``` if you want to also run the EDA files
|
49 |
```bash
|
50 |
pip install -r requirements.txt
|
51 |
```
|
52 |
+
- If there are no errors, you should be able to run the app smoothly.
|
53 |
- Remember to run everything inside your virtual environment.
|
54 |
|
55 |
### Running the Application
|
klimainsights/pages/__pycache__/biodiversity.cpython-311.pyc
CHANGED
Binary files a/klimainsights/pages/__pycache__/biodiversity.cpython-311.pyc and b/klimainsights/pages/__pycache__/biodiversity.cpython-311.pyc differ
|
|
klimainsights/pages/__pycache__/disaster.cpython-311.pyc
CHANGED
Binary files a/klimainsights/pages/__pycache__/disaster.cpython-311.pyc and b/klimainsights/pages/__pycache__/disaster.cpython-311.pyc differ
|
|
klimainsights/pages/biodiversity.py
CHANGED
@@ -134,7 +134,7 @@ def update_bar(region, species_type, bio_switch, click_data):
|
|
134 |
# filtered_data = biodiversity_gdf[(biodiversity_gdf['area_type'].isin(['Sea']))].reset_index().drop(columns='index')
|
135 |
# else:
|
136 |
|
137 |
-
filtered_data = biodiversity_gdf[biodiversity_gdf['island_group'] == region].sort_values(by=species_type, ascending=True
|
138 |
|
139 |
if species_type == "total_species":
|
140 |
txt = "Total"
|
|
|
134 |
# filtered_data = biodiversity_gdf[(biodiversity_gdf['area_type'].isin(['Sea']))].reset_index().drop(columns='index')
|
135 |
# else:
|
136 |
|
137 |
+
filtered_data = biodiversity_gdf[biodiversity_gdf['island_group'] == region].sort_values(by=species_type, ascending=True, ignore_index=True)
|
138 |
|
139 |
if species_type == "total_species":
|
140 |
txt = "Total"
|
klimainsights/pages/disaster.py
CHANGED
@@ -142,7 +142,7 @@ def update_line(division, click_data):
|
|
142 |
else:
|
143 |
return
|
144 |
|
145 |
-
island_gdf = temp_melted_gdf[(temp_melted_gdf[curr_div].isin([data]) == True)].drop(columns=['geometry'])
|
146 |
|
147 |
line_fig = px.line(island_gdf, x='decade', y='value',color='name')
|
148 |
line_fig.update_layout(
|
@@ -167,7 +167,7 @@ def update_line(division, click_data):
|
|
167 |
}],
|
168 |
xaxis_tickangle=-45
|
169 |
)
|
170 |
-
hover_template = '<
|
171 |
line_fig.update_traces(hovertemplate=hover_template)
|
172 |
|
173 |
return line_fig
|
@@ -278,9 +278,7 @@ def update_disaster_bar(division, disaster_type, island_group):
|
|
278 |
curr_disaster = 'Region_drought'
|
279 |
case _:
|
280 |
return
|
281 |
-
island_disaster = Region_gdf[Region_gdf['Island Group'] == island_group].groupby('Region')
|
282 |
-
x = island_disaster.values
|
283 |
-
y = island_disaster.index
|
284 |
elif division == 'Province':
|
285 |
curr_division = 'Area Name'
|
286 |
match disaster_type:
|
@@ -300,12 +298,13 @@ def update_disaster_bar(division, disaster_type, island_group):
|
|
300 |
curr_disaster = 'Drought Count'
|
301 |
case _:
|
302 |
return
|
303 |
-
island_disaster = Region_gdf[(Region_gdf['Island Group'] == island_group)].sort_values(by=
|
304 |
-
x = curr_disaster
|
305 |
-
y = curr_division
|
306 |
else:
|
307 |
return
|
308 |
# Create stacked bar plot using Plotly Express
|
|
|
|
|
|
|
309 |
bar_fig = px.bar(island_disaster,
|
310 |
x=x,
|
311 |
y=y,
|
@@ -320,6 +319,6 @@ def update_disaster_bar(division, disaster_type, island_group):
|
|
320 |
)
|
321 |
hover_template = '<b>%{customdata[0]}</b><br>' + disaster_type + ' Count: %{x}<extra></extra>'
|
322 |
bar_fig.update_traces(hovertemplate=hover_template,
|
323 |
-
customdata=
|
324 |
-
|
325 |
return bar_fig
|
|
|
142 |
else:
|
143 |
return
|
144 |
|
145 |
+
island_gdf = temp_melted_gdf[(temp_melted_gdf[curr_div].isin([data]) == True)].drop(columns=['geometry']).sort_values(by=['name', 'decade'], ascending=True, ignore_index=True)
|
146 |
|
147 |
line_fig = px.line(island_gdf, x='decade', y='value',color='name')
|
148 |
line_fig.update_layout(
|
|
|
167 |
}],
|
168 |
xaxis_tickangle=-45
|
169 |
)
|
170 |
+
hover_template = '<br>Average Temperature in<br>the %{x}:<br><b>%{y:.2f}°C</b><extra></extra>'
|
171 |
line_fig.update_traces(hovertemplate=hover_template)
|
172 |
|
173 |
return line_fig
|
|
|
278 |
curr_disaster = 'Region_drought'
|
279 |
case _:
|
280 |
return
|
281 |
+
island_disaster = Region_gdf[Region_gdf['Island Group'] == island_group].drop(columns=['geometry', 'Area Name']).groupby(['Island Group', 'Region']).sum().reset_index().sort_values(by=curr_disaster, ascending=True, ignore_index=True)
|
|
|
|
|
282 |
elif division == 'Province':
|
283 |
curr_division = 'Area Name'
|
284 |
match disaster_type:
|
|
|
298 |
curr_disaster = 'Drought Count'
|
299 |
case _:
|
300 |
return
|
301 |
+
island_disaster = Region_gdf[(Region_gdf['Island Group'] == island_group)].drop(columns=['geometry']).sort_values(by=curr_disaster, ascending=True, ignore_index=True)
|
|
|
|
|
302 |
else:
|
303 |
return
|
304 |
# Create stacked bar plot using Plotly Express
|
305 |
+
|
306 |
+
x = curr_disaster
|
307 |
+
y = curr_division
|
308 |
bar_fig = px.bar(island_disaster,
|
309 |
x=x,
|
310 |
y=y,
|
|
|
319 |
)
|
320 |
hover_template = '<b>%{customdata[0]}</b><br>' + disaster_type + ' Count: %{x}<extra></extra>'
|
321 |
bar_fig.update_traces(hovertemplate=hover_template,
|
322 |
+
customdata=island_disaster[[curr_division]])
|
323 |
+
|
324 |
return bar_fig
|
plotly_interactions.ipynb
CHANGED
@@ -85,6 +85,15 @@
|
|
85 |
"temperature_gdf.head()"
|
86 |
]
|
87 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
{
|
89 |
"cell_type": "code",
|
90 |
"execution_count": null,
|
@@ -342,9 +351,9 @@
|
|
342 |
" else:\n",
|
343 |
" return\n",
|
344 |
"\n",
|
345 |
-
" island_gdf = temp_melted_gdf[(temp_melted_gdf[curr_div].isin([data]) == True)].drop(columns=['geometry'])\n",
|
346 |
"\n",
|
347 |
-
" line_fig = px.line(island_gdf, x='decade', y='value',color='name')\n",
|
348 |
" line_fig.update_layout(\n",
|
349 |
" autosize=True, \n",
|
350 |
" height=700,\n",
|
@@ -367,12 +376,12 @@
|
|
367 |
" }],\n",
|
368 |
" xaxis_tickangle=-45 \n",
|
369 |
" )\n",
|
370 |
-
" hover_template = '<
|
371 |
" line_fig.update_traces(hovertemplate=hover_template)\n",
|
372 |
"\n",
|
373 |
" return line_fig\n",
|
374 |
"\n",
|
375 |
-
"done = update_line('
|
376 |
"done.show()"
|
377 |
]
|
378 |
},
|
@@ -985,9 +994,7 @@
|
|
985 |
" curr_disaster = 'Region_drought'\n",
|
986 |
" case _:\n",
|
987 |
" return\n",
|
988 |
-
" island_disaster = Region_gdf[Region_gdf['Island Group'] == island_group].groupby('Region')
|
989 |
-
" x = island_disaster.values\n",
|
990 |
-
" y = island_disaster.index\n",
|
991 |
" elif division == 'Province':\n",
|
992 |
" curr_division = 'Area Name'\n",
|
993 |
" match disaster_type:\n",
|
@@ -1007,12 +1014,13 @@
|
|
1007 |
" curr_disaster = 'Drought Count'\n",
|
1008 |
" case _:\n",
|
1009 |
" return\n",
|
1010 |
-
" island_disaster = Region_gdf[(Region_gdf['Island Group'] == island_group)].sort_values(by=
|
1011 |
-
" x = curr_disaster\n",
|
1012 |
-
" y = curr_division\n",
|
1013 |
" else:\n",
|
1014 |
" return\n",
|
1015 |
" # Create stacked bar plot using Plotly Express\n",
|
|
|
|
|
|
|
1016 |
" bar_fig = px.bar(island_disaster,\n",
|
1017 |
" x=x, \n",
|
1018 |
" y=y, \n",
|
@@ -1027,11 +1035,11 @@
|
|
1027 |
" )\n",
|
1028 |
" hover_template = '<b>%{customdata[0]}</b><br>' + disaster_type + ' Count: %{x}<extra></extra>'\n",
|
1029 |
" bar_fig.update_traces(hovertemplate=hover_template,\n",
|
1030 |
-
" customdata=
|
1031 |
-
"\n",
|
1032 |
" return bar_fig\n",
|
1033 |
"\n",
|
1034 |
-
"test = update_disaster_bar('
|
1035 |
"test.show()"
|
1036 |
]
|
1037 |
},
|
|
|
85 |
"temperature_gdf.head()"
|
86 |
]
|
87 |
},
|
88 |
+
{
|
89 |
+
"cell_type": "code",
|
90 |
+
"execution_count": null,
|
91 |
+
"metadata": {},
|
92 |
+
"outputs": [],
|
93 |
+
"source": [
|
94 |
+
"temp_melted_gdf.head()"
|
95 |
+
]
|
96 |
+
},
|
97 |
{
|
98 |
"cell_type": "code",
|
99 |
"execution_count": null,
|
|
|
351 |
" else:\n",
|
352 |
" return\n",
|
353 |
"\n",
|
354 |
+
" island_gdf = temp_melted_gdf[(temp_melted_gdf[curr_div].isin([data]) == True)].drop(columns=['geometry']).sort_values(by=['name', 'decade'], ascending=True, ignore_index=True)\n",
|
355 |
"\n",
|
356 |
+
" line_fig = px.line(island_gdf, x='decade', y='value', color='name')\n",
|
357 |
" line_fig.update_layout(\n",
|
358 |
" autosize=True, \n",
|
359 |
" height=700,\n",
|
|
|
376 |
" }],\n",
|
377 |
" xaxis_tickangle=-45 \n",
|
378 |
" )\n",
|
379 |
+
" hover_template = '<br>Average Temperature in<br>the %{x}:<br><b>%{y:.2f}°C</b><extra></extra>'\n",
|
380 |
" line_fig.update_traces(hovertemplate=hover_template)\n",
|
381 |
"\n",
|
382 |
" return line_fig\n",
|
383 |
"\n",
|
384 |
+
"done = update_line('Province', 'Abra')\n",
|
385 |
"done.show()"
|
386 |
]
|
387 |
},
|
|
|
994 |
" curr_disaster = 'Region_drought'\n",
|
995 |
" case _:\n",
|
996 |
" return\n",
|
997 |
+
" island_disaster = Region_gdf[Region_gdf['Island Group'] == island_group].drop(columns=['geometry', 'Area Name']).groupby(['Island Group', 'Region']).sum().reset_index().sort_values(by=curr_disaster, ascending=True, ignore_index=True)\n",
|
|
|
|
|
998 |
" elif division == 'Province':\n",
|
999 |
" curr_division = 'Area Name'\n",
|
1000 |
" match disaster_type:\n",
|
|
|
1014 |
" curr_disaster = 'Drought Count'\n",
|
1015 |
" case _:\n",
|
1016 |
" return\n",
|
1017 |
+
" island_disaster = Region_gdf[(Region_gdf['Island Group'] == island_group)].drop(columns=['geometry']).sort_values(by=curr_disaster, ascending=True, ignore_index=True)\n",
|
|
|
|
|
1018 |
" else:\n",
|
1019 |
" return\n",
|
1020 |
" # Create stacked bar plot using Plotly Express\n",
|
1021 |
+
"\n",
|
1022 |
+
" x = curr_disaster\n",
|
1023 |
+
" y = curr_division\n",
|
1024 |
" bar_fig = px.bar(island_disaster,\n",
|
1025 |
" x=x, \n",
|
1026 |
" y=y, \n",
|
|
|
1035 |
" )\n",
|
1036 |
" hover_template = '<b>%{customdata[0]}</b><br>' + disaster_type + ' Count: %{x}<extra></extra>'\n",
|
1037 |
" bar_fig.update_traces(hovertemplate=hover_template,\n",
|
1038 |
+
" customdata=island_disaster[[curr_division]])\n",
|
1039 |
+
" \n",
|
1040 |
" return bar_fig\n",
|
1041 |
"\n",
|
1042 |
+
"test = update_disaster_bar('Region', 'Total Disaster', 'Luzon')\n",
|
1043 |
"test.show()"
|
1044 |
]
|
1045 |
},
|