YashMK89 commited on
Commit
9d458b0
·
verified ·
1 Parent(s): fe61a21

update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -10
app.py CHANGED
@@ -5,7 +5,6 @@ import os
5
  import pandas as pd
6
  import geopandas as gpd
7
  from datetime import datetime
8
- from shapely.geometry import Point
9
  import leafmap.foliumap as leafmap
10
 
11
  # Set up the page layout
@@ -53,6 +52,9 @@ st.header("Earth Engine Index Calculator")
53
  # Choose Index or Custom Formula
54
  index_choice = st.selectbox("Select an Index or Enter Custom Formula", ['NDVI', 'NDWI', 'Average NO₂', 'Custom Formula'])
55
 
 
 
 
56
  # Display corresponding formula based on the index selected
57
  if index_choice == 'NDVI':
58
  st.write("Formula for NDVI: NDVI = (B8 - B4) / (B8 + B4)")
@@ -60,13 +62,9 @@ elif index_choice == 'NDWI':
60
  st.write("Formula for NDWI: NDWI = (B3 - B8) / (B3 + B8)")
61
  elif index_choice == 'Average NO₂':
62
  st.write("Formula for Average NO₂: Average NO₂ = Mean(NO2 band)")
63
- elif index_choice == 'Custom Formula' and custom_formula:
64
- st.write(f"Custom Formula: {custom_formula}")
65
-
66
- # Enter custom formula if selected
67
- custom_formula = ""
68
- if index_choice == 'Custom Formula':
69
  custom_formula = st.text_input("Enter Custom Formula (e.g., 'B5 - B4 / B5 + B4')")
 
70
 
71
  # Function to read points from CSV
72
  def read_csv(file_path):
@@ -280,12 +278,11 @@ if file_upload:
280
  if st.session_state.results:
281
  # Convert the results to a DataFrame for better visualization
282
  result_df = pd.DataFrame(st.session_state.results)
283
-
284
  # Show the results in a table format
285
  st.write("Processed Results Table:")
286
- st.dataframe(result_df)
287
 
288
- # Allow user to download results as CSV
289
  st.download_button(
290
  label="Download results as CSV",
291
  data=result_df.to_csv(index=False).encode('utf-8'),
 
5
  import pandas as pd
6
  import geopandas as gpd
7
  from datetime import datetime
 
8
  import leafmap.foliumap as leafmap
9
 
10
  # Set up the page layout
 
52
  # Choose Index or Custom Formula
53
  index_choice = st.selectbox("Select an Index or Enter Custom Formula", ['NDVI', 'NDWI', 'Average NO₂', 'Custom Formula'])
54
 
55
+ # Initialize custom_formula variable
56
+ custom_formula = ""
57
+
58
  # Display corresponding formula based on the index selected
59
  if index_choice == 'NDVI':
60
  st.write("Formula for NDVI: NDVI = (B8 - B4) / (B8 + B4)")
 
62
  st.write("Formula for NDWI: NDWI = (B3 - B8) / (B3 + B8)")
63
  elif index_choice == 'Average NO₂':
64
  st.write("Formula for Average NO₂: Average NO₂ = Mean(NO2 band)")
65
+ elif index_choice == 'Custom Formula':
 
 
 
 
 
66
  custom_formula = st.text_input("Enter Custom Formula (e.g., 'B5 - B4 / B5 + B4')")
67
+ st.write(f"Custom Formula: {custom_formula}") # Display the custom formula after the user inputs it
68
 
69
  # Function to read points from CSV
70
  def read_csv(file_path):
 
278
  if st.session_state.results:
279
  # Convert the results to a DataFrame for better visualization
280
  result_df = pd.DataFrame(st.session_state.results)
281
+
282
  # Show the results in a table format
283
  st.write("Processed Results Table:")
284
+ st.dataframe(result_df)
285
 
 
286
  st.download_button(
287
  label="Download results as CSV",
288
  data=result_df.to_csv(index=False).encode('utf-8'),