YashMK89 commited on
Commit
db652ad
·
verified ·
1 Parent(s): d050e82

update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -3
app.py CHANGED
@@ -55,7 +55,6 @@ with open(os.path.expanduser("~/.config/earthengine/credentials"), "w") as f:
55
  f.write(earthengine_credentials)
56
 
57
  ee.Initialize(project='ee-yashsacisro24')
58
-
59
  # Imagery base selection
60
  imagery_base = st.selectbox("Select Imagery Base", ["Sentinel", "Landsat"], index=0)
61
 
@@ -74,8 +73,26 @@ st.title(f"{imagery_base} Dataset")
74
  # Select dataset category (main selection)
75
  main_selection = st.selectbox(f"Select {imagery_base} Dataset Category", list(data.keys()))
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  # Load band information based on selected dataset
78
- if main_selection and sub_selection:
79
  dataset_bands = data[main_selection]["bands"].get(sub_selection, [])
80
  st.write(f"Available Bands for {sub_options[sub_selection]}: {', '.join(dataset_bands)}")
81
 
@@ -114,7 +131,6 @@ if main_selection and sub_selection:
114
  # Validate the formula
115
  def validate_formula(formula, selected_bands):
116
  allowed_chars = set(" +-*/()0123456789.")
117
- # Match alphanumeric terms including underscores (for Landsat bands like SR_B1)
118
  terms = re.findall(r'[a-zA-Z][a-zA-Z0-9_]*', formula)
119
  invalid_terms = [term for term in terms if term not in selected_bands]
120
  if invalid_terms:
 
55
  f.write(earthengine_credentials)
56
 
57
  ee.Initialize(project='ee-yashsacisro24')
 
58
  # Imagery base selection
59
  imagery_base = st.selectbox("Select Imagery Base", ["Sentinel", "Landsat"], index=0)
60
 
 
73
  # Select dataset category (main selection)
74
  main_selection = st.selectbox(f"Select {imagery_base} Dataset Category", list(data.keys()))
75
 
76
+ # Initialize sub_selection and dataset_id as None
77
+ sub_selection = None
78
+ dataset_id = None
79
+
80
+ # If a category is selected, display the sub-options (specific datasets)
81
+ if main_selection:
82
+ sub_options = data[main_selection]["sub_options"]
83
+ sub_selection = st.selectbox(f"Select Specific {imagery_base} Dataset ID", list(sub_options.keys()))
84
+
85
+ # Display the selected dataset ID based on user input
86
+ if sub_selection:
87
+ st.write(f"You selected: {main_selection} -> {sub_options[sub_selection]}")
88
+ st.write(f"Dataset ID: {sub_selection}")
89
+ dataset_id = sub_selection # Use the key directly as the dataset ID
90
+
91
+ # Earth Engine Index Calculator Section
92
+ st.header("Earth Engine Index Calculator")
93
+
94
  # Load band information based on selected dataset
95
+ if main_selection and sub_selection: # Now safe because sub_selection is initialized
96
  dataset_bands = data[main_selection]["bands"].get(sub_selection, [])
97
  st.write(f"Available Bands for {sub_options[sub_selection]}: {', '.join(dataset_bands)}")
98
 
 
131
  # Validate the formula
132
  def validate_formula(formula, selected_bands):
133
  allowed_chars = set(" +-*/()0123456789.")
 
134
  terms = re.findall(r'[a-zA-Z][a-zA-Z0-9_]*', formula)
135
  invalid_terms = [term for term in terms if term not in selected_bands]
136
  if invalid_terms: