SATRANG / app.py
YashMK89's picture
update app.py
e070e1d verified
raw
history blame
1.58 kB
import streamlit as st
import json
st.set_page_config(layout="wide")
m = st.markdown(
"""
<style>
div.stButton > button:first-child {
background-color: #006400;
color:#ffffff;
}
</style>""",
unsafe_allow_html=True,
)
# Load JSON data from file
with open("sentinel_datasets.json") as f:
data = json.load(f)
# Display title
st.title("Sentinel Dataset Selector")
# Step 1: Select main dataset category
main_selection = st.selectbox("Select Sentinel Dataset Category", list(data.keys()))
# Step 2: Display sub-options based on main selection
if main_selection:
sub_options = data[main_selection]["sub_options"]
sub_selection = st.selectbox("Select Specific Dataset ID", list(sub_options.keys()))
# Step 3: Display band selection based on sub-selection with max 3 selections
if sub_selection:
bands = sub_options[sub_selection]
st.write("Select up to 3 bands:")
# Create a list to store selected bands
selected_bands = []
# Display checkboxes for each band with a maximum selection limit of 3
for band in bands:
if st.checkbox(band, key=band):
selected_bands.append(band)
# Limit selection to a maximum of 3 bands
if len(selected_bands) == 3:
break
# Show a warning if more than 3 bands are selected
if len(selected_bands) > 3:
st.warning("You can select a maximum of 3 bands.")
# Display selected bands
st.write("Selected Bands:", selected_bands)