update app.py
Browse files
app.py
CHANGED
@@ -14,24 +14,40 @@ div.stButton > button:first-child {
|
|
14 |
unsafe_allow_html=True,
|
15 |
)
|
16 |
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
# Load dataset categories and sub-options from JSON file
|
22 |
-
with open("datasets.json") as f:
|
23 |
-
sentinel_categories = json.load(f)
|
24 |
|
25 |
# Display title
|
26 |
st.title("Sentinel Dataset Selector")
|
27 |
|
28 |
-
#
|
29 |
-
main_selection = st.selectbox("Select Sentinel Dataset Category", list(
|
30 |
|
31 |
-
#
|
32 |
if main_selection:
|
33 |
-
sub_options =
|
34 |
-
sub_selection = st.selectbox("Select Specific Dataset", sub_options)
|
35 |
-
|
36 |
-
# Display
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
unsafe_allow_html=True,
|
15 |
)
|
16 |
|
17 |
+
# Load JSON data from file
|
18 |
+
with open("sentinel_datasets.json") as f:
|
19 |
+
data = json.load(f)
|
|
|
|
|
|
|
|
|
20 |
|
21 |
# Display title
|
22 |
st.title("Sentinel Dataset Selector")
|
23 |
|
24 |
+
# Step 1: Select main dataset category
|
25 |
+
main_selection = st.selectbox("Select Sentinel Dataset Category", list(data.keys()))
|
26 |
|
27 |
+
# Step 2: Display sub-options based on main selection
|
28 |
if main_selection:
|
29 |
+
sub_options = data[main_selection]["sub_options"]
|
30 |
+
sub_selection = st.selectbox("Select Specific Dataset ID", list(sub_options.keys()))
|
31 |
+
|
32 |
+
# Step 3: Display band selection based on sub-selection with max 3 selections
|
33 |
+
if sub_selection:
|
34 |
+
bands = sub_options[sub_selection]
|
35 |
+
st.write("Select up to 3 bands:")
|
36 |
+
|
37 |
+
# Create a list to store selected bands
|
38 |
+
selected_bands = []
|
39 |
+
|
40 |
+
# Display checkboxes for each band with a maximum selection limit of 3
|
41 |
+
for band in bands:
|
42 |
+
if st.checkbox(band, key=band):
|
43 |
+
selected_bands.append(band)
|
44 |
+
# Limit selection to a maximum of 3 bands
|
45 |
+
if len(selected_bands) == 3:
|
46 |
+
break
|
47 |
+
|
48 |
+
# Show a warning if more than 3 bands are selected
|
49 |
+
if len(selected_bands) > 3:
|
50 |
+
st.warning("You can select a maximum of 3 bands.")
|
51 |
+
|
52 |
+
# Display selected bands
|
53 |
+
st.write("Selected Bands:", selected_bands)
|