This application is designed to monitor and analyze hydrological changes in the Masurian region (Mazury, Poland) using satellite imagery and AI-based predictions. It uses data from Google Earth Engine (especially Sentinel-2 images) and hydrological data from Polish sources (like IMGW) to assess the impact of climate change and to predict future environmental shifts. Map Interactive spatial analysis Filters Dynamic data selection Charts Trends, analyses, predictions Simulations Impact of climate change Report Summary and recommendations
To upload files, please first save the app
import streamlit as st
import pandas as pd
import numpy as np
import folium
from streamlit_folium import folium_static
import plotly.express as px
import plotly.graph_objects as go
from datetime import datetime, timedelta
import matplotlib.pyplot as plt
from sklearn.linear_model import LinearRegression
from sklearn.preprocessing import PolynomialFeatures
# Page configuration
st.set_page_config(
page_title="Mazury Hydrological Monitor",
page_icon="🌊",
layout="wide"
)
# Title and description
st.title("Mazury Hydrological Monitor")
st.markdown("""
This application monitors and analyzes hydrological changes in the Masurian Lake District
using satellite imagery and AI-based predictions.
""")
# Sidebar filters
st.sidebar.header("Data Filters")
selected_year = st.sidebar.slider("Select Year", 2015, 2023, 2023)
selected_season = st.sidebar.selectbox(
"Select Season",
["Spring", "Summer", "Autumn", "Winter"]
)
selected_lake = st.sidebar.selectbox(
"Select Lake",
["Śniardwy", "Mamry", "Niegocin", "Mikołajskie", "Tałty"]
)
# Main content organized in tabs
tab1, tab2, tab3, tab4, tab5 = st.tabs([
"Map View",
"Data Analysis",
"Trends & Predictions",
"Climate Impact",
"Report"
])
# Sample data (in real application, this would come from actual sources)
def generate_sample_data():
dates = pd.date_range(start='2015-01-01', end='2023-12-31', freq='M')
np.random.seed(42)
water_levels = 100 + np.random.normal(0, 5, len(dates)) + \
np.sin(np.arange(len(dates)) * 2 * np.pi / 12) * 10
return pd.DataFrame({
'date': dates,
'water_level': water_levels,
'temperature': 15 + np.random.normal(0, 3, len(dates)) + \
np.sin(np.arange(len(dates)) * 2 * np.pi / 12) * 10
})
data = generate_sample_data()
with tab1:
st.header("Spatial Analysis")
# Create a map centered on Mazury
m = folium.Map(location=[53.8, 21.6], zoom_start=9)
# Add sample markers for lakes
lakes = {
"Åšniardwy": [53.7419, 21.7383],
"Mamry": [54.1311, 21.7828],
"Niegocin": [53.9131, 21.7492],
"Mikołajskie": [53.8006, 21.5856],
"Tałty": [53.9167, 21.5500]
}
for lake, coords in lakes.items():
folium.CircleMarker(
location=coords,
radius=10,
popup=lake,
color='blue' if lake == selected_lake else 'gray',
fill=True
).add_to(m)
# Display the map
folium_static(m)
with tab2:
st.header("Data Analysis")
# Create sample time series plot
fig = px.line(data, x='date', y='water_level',
title=f'Water Level Trends for {selected_lake}')
st.plotly_chart(fig, use_container_width=True)
# Add some statistics
col1, col2, col3 = st.columns(3)
with col1:
st.metric("Average Water Level", f"{data['water_level'].mean():.1f}m")
with col2:
st.metric("Max Level", f"{data['water_level'].max():.1f}m")
with col3:
st.metric("Min Level", f"{data['water_level'].min():.1f}m")
with tab3:
st.header("Trends & Predictions")
# Create a simple prediction model
X = np.arange(len(data)).reshape(-1, 1)
y = data['water_level']
model = LinearRegression()
model.fit(X, y)
# Generate future predictions
future_dates = pd.date_range(
start=data['date'].max(),
periods=24,
freq='M'
)
future_X = np.arange(len(data), len(data) + 24).reshape(-1, 1)
future_predictions = model.predict(future_X)
# Plot historical data and predictions
fig = go.Figure()
fig.add_trace(go.Scatter(
x=data['date'],
y=data['water_level'],
name='Historical Data'
))
fig.add_trace(go.Scatter(
x=future_dates,
y=future_predictions,
name='Predictions',
line=dict(dash='dash')
))
fig.update_layout(title='Water Level Predictions',
xaxis_title='Date',
yaxis_title='Water Level (m)')
st.plotly_chart(fig, use_container_width=True)
with tab4:
st.header("Climate Impact Simulation")
impact_severity = st.slider(
"Climate Change Severity",
min_value=1,
max_value=5,
value=3,
help="1 = Minimal impact, 5 = Severe impact"
)
# Simple simulation based on severity
baseline = data['water_level'].mean()
impact_factor = (impact_severity - 3) * 0.1 # 10% change per severity level
simulated_level = baseline * (1 + impact_factor)
st.metric(
"Projected Average Water Level",
f"{simulated_level:.1f}m",
f"{(simulated_level - baseline):.1f}m"
)
# Add impact visualization
impact_data = pd.DataFrame({
'Category': ['Biodiversity', 'Tourism', 'Agriculture', 'Water Quality'],
'Impact Score': np.random.normal(impact_severity, 0.5, 4)
})
fig = px.bar(impact_data, x='Category', y='Impact Score',
title='Projected Environmental Impact')
st.plotly_chart(fig, use_container_width=True)
with tab5:
st.header("Summary Report")
st.markdown(f"""
### Key Findings for {selected_lake}
#### Current Status
- Average water level: {data['water_level'].mean():.1f}m
- Annual variation: {data['water_level'].std():.1f}m
#### Predictions
- Short-term trend: {'Stable' if abs(model.coef_[0]) < 0.1 else 'Increasing' if model.coef_[0] > 0 else 'Decreasing'}
- Projected change: {(future_predictions[-1] - data['water_level'].iloc[-1]):.1f}m
#### Recommendations
1. {'Implement water conservation measures' if impact_severity > 3 else 'Monitor water levels regularly'}
2. {'Develop drought management plans' if impact_severity > 4 else 'Update environmental protection guidelines'}
3. {'Consider restrictions on water usage' if impact_severity > 3 else 'Promote sustainable tourism'}
""")
# Export options
if st.button("Generate PDF Report"):
st.info("PDF report generation would be implemented here")
Hi! I can help you with any questions about Streamlit and Python. What would you like to know?