-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.py
407 lines (312 loc) · 16.8 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
import datetime
import math
import folium
import geopandas as gpd
import geopy
import networkx as nx
import joblib
import osmnx as ox
import shapely.wkt
import pandas as pd
import streamlit as st
import streamlit.components.v1 as components
import time
import base64
from branca.element import Figure
from folium.features import DivIcon
from geopy.geocoders import Nominatim
from geopy.extra.rate_limiter import RateLimiter
from PIL import Image
from streamlit_folium import folium_static
from dateutil.relativedelta import relativedelta
from data_collection import *
from predict import *
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
import time
import geemap
st.set_page_config(
page_title="Water Quality Monitoring Dashboard for Kutch Region",
layout="wide",
initial_sidebar_state="expanded",
)
st.set_option('deprecation.showPyplotGlobalUse', False)
st.sidebar.markdown('<h1 style="margin-left:8%; color: #FF9933 ">Kutch Water Quality Monitoring Dashboard </h1>',
unsafe_allow_html=True)
add_selectbox = st.sidebar.radio(
"",
("Home", "About", "Features", "Select AOI Data Parameters", "Visualizations", "Conclusion", "Team")
)
if add_selectbox == 'Home':
LOGO_IMAGE = "omdena_india_logo.png"
st.markdown(
"""
<style>
.container {
display: flex;
}
.logo-text {
font-weight:700 !important;
font-size:50px !important;
color: #f9a01b !important;
padding-top: 75px !important;
}
.logo-img {
float:right;
}
</style>
""",
unsafe_allow_html=True
)
st.markdown(
f"""
<div class="container">
<img class="logo-img" src="data:image/png;base64,{base64.b64encode(open(LOGO_IMAGE, "rb").read()).decode()}">
</div>
""",
unsafe_allow_html=True
)
st.subheader('PROBLEM STATEMENT')
st.markdown('Our problem statement is to develop a centralized dashboard with different water quality parameters for analyzing, interpretation, and visualization in near real-time using Remote Sensing and AI for better decision making. This will identify if any parameter is not within standard limits for taking up an immediate action and reinforce the abilities to monitor water quality more effectively & efficiently.',
unsafe_allow_html=True)
elif add_selectbox == 'About':
st.subheader('ABOUT THE PROJECT')
st.markdown('<h4>Project Goals</h4>', unsafe_allow_html=True)
st.markdown('• Water Quality Indicator Dashboard for Analysis, Interpretation and Visualization near Real Time', unsafe_allow_html=True)
st.markdown('• Compare Real Water Quality Parameters with Standard Water Quality Limits', unsafe_allow_html=True)
st.markdown('<h4>Locations Choosen</h4>', unsafe_allow_html=True)
st.markdown('Harmisar Lake, Shinai Lake, Tappar Lake',
unsafe_allow_html=True)
st.markdown('<h4>Developments Made</h4>', unsafe_allow_html=True)
st.markdown('• Water Quality Parameters were identified which includes physical, biological and chemical parameters',unsafe_allow_html=True)
st.markdown('• Research papers were reviewed and important points were noted for different remote sensing data used with machine learning and different satellite sources were revised properly.',unsafe_allow_html=True)
st.markdown('• Various Data sources were searched in Google Earth Engine and relevant sources were selected for our use-case.',unsafe_allow_html=True)
st.markdown('• Analysed the images from the selected sources and applied various standard formulae were applied to analyse the colours of the water body regions.',unsafe_allow_html=True)
st.markdown('• Final water quality parameters were selected and their names listed along with their band formulae.',unsafe_allow_html=True)
st.markdown('• Various Machine learning models were applied on the final dataframe and the metrics were analysed and the best model was chosen with having a good validation accuracy.',unsafe_allow_html=True)
st.markdown('• A visualisation dashboard is created for the public to enter coordinates, their region of interest(water-body) and the data range to get the water quality for that area along with data visualisation of the collected data from the satellites.',unsafe_allow_html=True)
elif add_selectbox == 'Features':
st.subheader('PROJECT ENDORSEMENTS')
st.markdown('• Projecting the quality of water bodies in the Kutch Region', unsafe_allow_html=True)
st.markdown('• Making it more centralized to analyze and monitor the existing water-body conditions', unsafe_allow_html=True)
st.markdown('• Identification of parameters compared with the standard threshold values', unsafe_allow_html=True)
elif add_selectbox == 'Select AOI Data Parameters':
st.subheader('SELECT FOR AOI DATA PARAMETERS')
col1, col2 = st.columns(2)
# aoi_type = col1.selectbox(
# "Select Area of Interest (AOI)",
# ("Shinai Lake","Harmirsar Lake", "Tappar Reservoir Lake")
# )
area = st.text_input('Type Area Of Interest', 'Water Body')
prm_type = col1.selectbox(
"Data Visualization Parameters",
("All","pH","Salinity","Turbidity","Land Surface Temperature","Chlorophyll","Suspended matter",
"Dissolved Organic Matter","Dissolved Oxygen")
)
long = st.number_input('Longitude',min_value=72.6026 , format="%.4f")
lat = st.number_input('Latitude', min_value =23.0063 ,format="%.4f")
col3,_ = st.columns((1,2)) # To make it narrower
format = 'MMM DD, YYYY' # format output
start1 = datetime.date(year=2024,month=1,day=1)-relativedelta(years=5) # I need some range in the past
start2 = datetime.date(year=2024,month=11,day=1)
st.text("")
st.text("")
st.write("Note-1:The difference between start date and end date should not exceed more than 4 months.")
st.text("")
st.text("")
st.write("Note-2: The minimum difference between start date and end date should be 2 months.")
st.text("")
st.text("")
max_days = start2-start1
slider1 = col3.slider('Select Start Date', min_value=start1, value=start2 ,max_value=start2, format=format)
## Sanity check
st.table(pd.DataFrame([[start1, slider1,start2]],
columns=['start1',
'start_selected',
'start2'],
index=['date']))
end1 = datetime.date(year=2024,month=2,day=28)-relativedelta(years=5) # I need some range in the past
end2 = datetime.date(year=2024,month=12,day=31)
max_days = end2-end1
slider2 = col3.slider('Select End Date', min_value=end1, value=end2, max_value=end2, format=format)
## Sanity check
st.table(pd.DataFrame([[end1, slider2, end2]],
columns=['end1',
'end_selected',
'end2'],
index=['date']))
def plot_do(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(25,10))
ax = sns.histplot(df_all['Dissolved Oxygen'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
# ax.set_xticks(np.arange(math.floor(df_all['Dissolved Oxygen'].min()), df_all['Dissolved Oxygen'].max() + 1, 0.5))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_dom(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(30,8))
ax = sns.histplot(df_all['Dissolved Organic Matter'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
ax.set_xticks(np.arange(math.floor(df_all['Dissolved Organic Matter'].min()),df_all['Dissolved Organic Matter'].max() + 2, 20))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_salinity(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(20,8))
ax = sns.histplot(df_all['Salinity'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
# ax.set_xticks(np.arange(math.floor(df_all['Salinity'].min()),df_all['Salinity'].max() + 0.1, 0.01))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_turbidity(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(30,8))
ax = sns.histplot(df_all['Turbidity'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
# ax.set_xticks(np.arange(math.floor(df_all['Turbidity'].min()),df_all['Turbidity'].max() + 0.01, 0.3))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_temperature(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(30,8))
ax = sns.histplot(df_all['Temperature'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
ax.set_xticks(np.arange(math.floor(df_all['Temperature'].min()),df_all['Temperature'].max() + 1, 0.5))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_chlorophyll(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(30,8))
ax = sns.histplot(df_all['Chlorophyll'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
# ax.set_xticks(np.arange(math.floor(df_all['Chlorophyll'].min()),df_all['Chlorophyll'].max() + 0.1, 0.01))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_pH(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(18,8))
ax = sns.histplot(df_all['pH'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
ax.set_xticks(np.arange(math.floor(df_all['pH'].min()), df_all['pH'].max() + 1, 0.1))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
def plot_sm(df_all):
mpl.rcParams.update({"axes.grid" : True, "grid.color": "black"})
sns.set(font_scale = 1)
fig = plt.figure(figsize=(20,9))
ax = sns.histplot(df_all['Suspended Matter'], kde=True, stat="density")
ax.tick_params(axis='y', colors='black')
ax.tick_params(axis='x', colors='black')
ax.set_xticks(np.arange(math.floor(df_all['Suspended Matter'].min()),df_all['Suspended Matter'].max() + 100, 20))
plt.setp(ax.get_xticklabels(), rotation=-10)
st.pyplot(fig, clear_figure = True)
if st.button('Submit'):
# try:
st.text("")
st.text("")
st.write("Note-3: The location is pointed with a big black dot on the map, kindly magnify to view more.")
st.text("")
st.text("")
df2 = get_data(long, lat, str(slider1), str(slider2))
st.text("")
st.text("")
st.write(df2)
df_all, test = send_df(df2)
st.text("")
st.text("")
st.text("")
st.write(predict_quality(df2, test))
st.text("")
st.text("")
st.text("")
if prm_type == 'Dissolved Oxygen':
plot_do(df_all)
elif prm_type == 'Salinity':
plot_salinity(df_all)
elif prm_type == 'Land Surface Temperature':
plot_temperature(df_all)
elif prm_type == 'Turbidity':
plot_turbidity(df_all)
elif prm_type == 'pH':
plot_pH(df_all)
elif prm_type == 'Chlorophyll':
plot_chlorophyll(df_all)
elif prm_type == 'Suspended Matter':
plot_sm(df_all)
elif prm_type == 'Dissolved Organic Matter':
plot_dom(df_all)
else:
plot_dom(df_all)
plot_pH(df_all)
plot_sm(df_all)
plot_chlorophyll(df_all)
plot_turbidity(df_all)
plot_temperature(df_all)
plot_salinity(df_all)
plot_do(df_all)
# except:
# st.write("!! Enter proper date range !!")
elif add_selectbox == 'Visualizations':
st.subheader('PROJECT VISUALIZATIONS')
st.markdown('<h4>Harmisar Lake</h4>', unsafe_allow_html=True)
st.image("harmisar_lake.png", width=400)
st.markdown('<h4>Shinai Lake</h4>', unsafe_allow_html=True)
st.image("shinai_lake.png", width=400)
st.markdown('<h4>Tappar Lake</h4>', unsafe_allow_html=True)
st.image("tappar_lake.png", width=400)
#st.markdown('<h4></h4>', unsafe_allow_html=True)
#st.image("", width=500)
elif add_selectbox == 'Conclusion':
st.subheader('TECH STACK')
st.markdown('• Data Collection - Google Earth Datasets', unsafe_allow_html=True)
st.markdown('• Data Visualization - Google Earth Engine', unsafe_allow_html=True)
st.markdown('• Satellite Imagery Analysis - Google Earth Engine', unsafe_allow_html=True)
st.markdown('• Machine Learning - Python, Jupyter Notebooks, Random Forest', unsafe_allow_html=True)
st.markdown('• Dashboard - Streamlit, Heroku', unsafe_allow_html=True)
st.subheader('PROJECT SUMMARY')
st.markdown('', unsafe_allow_html=True)
st.markdown('• Water quality is one of the main challenges that societies are facing in the 21st century, threatening human health, limiting food production, reducing ecosystem functions, and hindering economic growth. It corrupts straightforwardly into ecological, financial, and social issues.', unsafe_allow_html=True)
st.markdown('• This dashboard will reinforce the abilities of decision-makers to monitor water quality more effectively and efficiently.', unsafe_allow_html=True)
st.markdown('• As the traditional in situ method is costly as well as time-consuming so using advanced geospatial technology water quality can be monitored spatially and temporally in near real- time and self-operating.', unsafe_allow_html=True)
st.subheader('CONCLUSION')
st.markdown('We have created a centralized dashboard to check on with the water conditions visually in real-time. This would help in addressing the water quality needs arised so as to give immediate attention to the users', unsafe_allow_html=True)
elif add_selectbox == 'Team':
st.subheader('COLLABORATORS')
st.markdown('• <a href="https://www.linkedin.com/in/tanisha-banik-04b511173/">Tanisha Banik</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/renju-zachariah-30982247/">Renju Zacharaiah</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/ishita-kheria-20b1b31ab/">Ishita Kheria</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/sairam-kannan-8648a0138/">SaiRam Kannan</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/prathima-kadari/">Prathima Kadari</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/himanshu-mishra-851459b5/">Himanshu Mishra</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/bharati-panigrahi-10a9461a0/">Bharati Panigrahi</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/deepali-bidwai/">Deepali Bidwai</a>',
unsafe_allow_html=True)
st.markdown('• <a href="https://www.linkedin.com/in/drij-chudasama-2a112a168/">Drij Chudasama</a>',
unsafe_allow_html=True)
st.markdown('• <a href="">Kiran Ryakala</a>',
unsafe_allow_html=True)
st.subheader('PROJECT MANAGER')
st.markdown('• <a href="https://www.linkedin.com/in/chancy-shah-671787119/">Chancy Shah</a>', unsafe_allow_html=True)