Update app.py
Browse files
app.py
CHANGED
|
@@ -3,6 +3,35 @@ import pandas as pd
|
|
| 3 |
import plotly.express as px
|
| 4 |
import pydeck as pdk
|
| 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
# Set page layout
|
| 7 |
st.set_page_config(page_title="Air Quality Dashboard", layout="wide")
|
| 8 |
|
|
@@ -20,26 +49,32 @@ aqi_data = {
|
|
| 20 |
}
|
| 21 |
|
| 22 |
# Main header
|
| 23 |
-
st.
|
| 24 |
|
| 25 |
# Display AQI information for the selected station
|
| 26 |
station_data = aqi_data[selected_station]
|
| 27 |
col1, col2 = st.columns(2)
|
| 28 |
|
|
|
|
| 29 |
with col1:
|
|
|
|
| 30 |
st.metric(label="Air Quality Index (AQI)", value=station_data["AQI"])
|
| 31 |
-
st.write(f"Top Pollutant
|
| 32 |
-
st.write(f"Concentration
|
|
|
|
| 33 |
|
|
|
|
| 34 |
with col2:
|
|
|
|
| 35 |
if station_data["AQI"] <= 50:
|
| 36 |
-
st.
|
| 37 |
elif station_data["AQI"] <= 100:
|
| 38 |
st.info("Not Bad!")
|
| 39 |
elif station_data["AQI"] <= 150:
|
| 40 |
st.warning("Low Air Quality")
|
| 41 |
else:
|
| 42 |
-
st.
|
|
|
|
| 43 |
|
| 44 |
# Impact message section
|
| 45 |
st.subheader("What This Means for You")
|
|
@@ -61,9 +96,7 @@ map_data = pd.DataFrame(
|
|
| 61 |
]
|
| 62 |
)
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
# Display map points with AQI severity coloring
|
| 67 |
aqi_map = pdk.Deck(
|
| 68 |
map_style="mapbox://styles/mapbox/light-v9",
|
| 69 |
initial_view_state=pdk.ViewState(
|
|
|
|
| 3 |
import plotly.express as px
|
| 4 |
import pydeck as pdk
|
| 5 |
|
| 6 |
+
# Custom CSS for styling
|
| 7 |
+
st.markdown("""
|
| 8 |
+
<style>
|
| 9 |
+
.metric-card {
|
| 10 |
+
background-color: #f0f4f8;
|
| 11 |
+
padding: 20px;
|
| 12 |
+
border-radius: 10px;
|
| 13 |
+
box-shadow: 2px 2px 10px rgba(0, 0, 0, 0.1);
|
| 14 |
+
margin: 10px;
|
| 15 |
+
font-family: 'Arial', sans-serif;
|
| 16 |
+
}
|
| 17 |
+
.header-text {
|
| 18 |
+
font-size: 24px;
|
| 19 |
+
font-weight: bold;
|
| 20 |
+
color: #333;
|
| 21 |
+
text-align: center;
|
| 22 |
+
margin-bottom: 20px;
|
| 23 |
+
}
|
| 24 |
+
.highlight-good {
|
| 25 |
+
color: #2ecc71;
|
| 26 |
+
font-weight: bold;
|
| 27 |
+
}
|
| 28 |
+
.highlight-bad {
|
| 29 |
+
color: #e74c3c;
|
| 30 |
+
font-weight: bold;
|
| 31 |
+
}
|
| 32 |
+
</style>
|
| 33 |
+
""", unsafe_allow_html=True)
|
| 34 |
+
|
| 35 |
# Set page layout
|
| 36 |
st.set_page_config(page_title="Air Quality Dashboard", layout="wide")
|
| 37 |
|
|
|
|
| 49 |
}
|
| 50 |
|
| 51 |
# Main header
|
| 52 |
+
st.markdown("<div class='header-text'>Louisville Air Watch</div>", unsafe_allow_html=True)
|
| 53 |
|
| 54 |
# Display AQI information for the selected station
|
| 55 |
station_data = aqi_data[selected_station]
|
| 56 |
col1, col2 = st.columns(2)
|
| 57 |
|
| 58 |
+
# AQI Display Card
|
| 59 |
with col1:
|
| 60 |
+
st.markdown("<div class='metric-card'>", unsafe_allow_html=True)
|
| 61 |
st.metric(label="Air Quality Index (AQI)", value=station_data["AQI"])
|
| 62 |
+
st.write(f"**Top Pollutant:** {station_data['Pollutant']}")
|
| 63 |
+
st.write(f"**Concentration:** {station_data.get('CO_ppb', station_data.get('PM25_ug/m3', 'N/A'))} ppb/µg/m³")
|
| 64 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 65 |
|
| 66 |
+
# Health Message Card
|
| 67 |
with col2:
|
| 68 |
+
st.markdown("<div class='metric-card'>", unsafe_allow_html=True)
|
| 69 |
if station_data["AQI"] <= 50:
|
| 70 |
+
st.write("<div class='highlight-good'>That's Good!</div>", unsafe_allow_html=True)
|
| 71 |
elif station_data["AQI"] <= 100:
|
| 72 |
st.info("Not Bad!")
|
| 73 |
elif station_data["AQI"] <= 150:
|
| 74 |
st.warning("Low Air Quality")
|
| 75 |
else:
|
| 76 |
+
st.write("<div class='highlight-bad'>Hazardous Air Quality</div>", unsafe_allow_html=True)
|
| 77 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
| 78 |
|
| 79 |
# Impact message section
|
| 80 |
st.subheader("What This Means for You")
|
|
|
|
| 96 |
]
|
| 97 |
)
|
| 98 |
|
| 99 |
+
# Plot Map using Pydeck
|
|
|
|
|
|
|
| 100 |
aqi_map = pdk.Deck(
|
| 101 |
map_style="mapbox://styles/mapbox/light-v9",
|
| 102 |
initial_view_state=pdk.ViewState(
|