YashMK89 commited on
Commit
f1fa2f5
·
verified ·
1 Parent(s): 8bb820f

update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -3
app.py CHANGED
@@ -49,6 +49,10 @@ ee.Initialize(project='ee-yashsacisro24')
49
  with open("sentinel_datasets.json") as f:
50
  data = json.load(f)
51
 
 
 
 
 
52
  # Display the title and dataset selection
53
  st.title("Sentinel Dataset")
54
 
@@ -68,6 +72,12 @@ index_choice = st.selectbox("Select an Index or Enter Custom Formula", ['NDVI',
68
  # Initialize custom_formula variable
69
  custom_formula = ""
70
 
 
 
 
 
 
 
71
  # Display corresponding formula based on the index selected (case-insensitive)
72
  if index_choice.lower() == 'ndvi':
73
  st.write("Formula for NDVI: NDVI = (B8 - B4) / (B8 + B4)")
@@ -76,10 +86,8 @@ elif index_choice.lower() == 'ndwi':
76
  elif index_choice.lower() == 'average no₂':
77
  st.write("Formula for Average NO₂: Average NO₂ = Mean(NO2 band)")
78
  elif index_choice.lower() == 'custom formula':
79
- # Get the bands for the selected dataset category
80
- bands = data[main_selection]["bands"]
81
  # Allow the user to select up to 3 bands
82
- band_selection = st.multiselect("Select up to 3 bands for custom calculation", bands, max_selections=3)
83
 
84
  # Show the selected bands in the custom formula input
85
  if len(band_selection) > 0:
 
49
  with open("sentinel_datasets.json") as f:
50
  data = json.load(f)
51
 
52
+ # Load the band options from band_options.json file
53
+ with open("band_options.json") as f:
54
+ band_options = json.load(f)
55
+
56
  # Display the title and dataset selection
57
  st.title("Sentinel Dataset")
58
 
 
72
  # Initialize custom_formula variable
73
  custom_formula = ""
74
 
75
+ # Get the available bands for the selected dataset category and subcategory
76
+ if main_selection and sub_selection:
77
+ available_bands = band_options.get(main_selection, {}).get(sub_selection, [])
78
+ else:
79
+ available_bands = []
80
+
81
  # Display corresponding formula based on the index selected (case-insensitive)
82
  if index_choice.lower() == 'ndvi':
83
  st.write("Formula for NDVI: NDVI = (B8 - B4) / (B8 + B4)")
 
86
  elif index_choice.lower() == 'average no₂':
87
  st.write("Formula for Average NO₂: Average NO₂ = Mean(NO2 band)")
88
  elif index_choice.lower() == 'custom formula':
 
 
89
  # Allow the user to select up to 3 bands
90
+ band_selection = st.multiselect("Select up to 3 bands for custom calculation", available_bands, max_selections=3)
91
 
92
  # Show the selected bands in the custom formula input
93
  if len(band_selection) > 0: