update app.py
Browse files
app.py
CHANGED
@@ -3,16 +3,19 @@ import json
|
|
3 |
import ee
|
4 |
import geemap
|
5 |
import os
|
|
|
6 |
|
7 |
st.set_page_config(layout="wide")
|
|
|
|
|
8 |
m = st.markdown(
|
9 |
"""
|
10 |
-
<style>
|
11 |
-
div.stButton > button:first-child {
|
12 |
-
|
13 |
-
|
14 |
-
}
|
15 |
-
</style>""",
|
16 |
unsafe_allow_html=True,
|
17 |
)
|
18 |
|
@@ -26,18 +29,6 @@ with open(os.path.expanduser("~/.config/earthengine/credentials"), "w") as f:
|
|
26 |
|
27 |
ee.Initialize(project='ee-yashsacisro24')
|
28 |
|
29 |
-
import streamlit as st
|
30 |
-
import ee
|
31 |
-
import geemap
|
32 |
-
import json
|
33 |
-
|
34 |
-
# Initialize Earth Engine
|
35 |
-
try:
|
36 |
-
ee.Initialize()
|
37 |
-
except ee.EEException as e:
|
38 |
-
st.error("Error initializing Earth Engine. Ensure your credentials are set up.")
|
39 |
-
st.stop()
|
40 |
-
|
41 |
# Load Sentinel dataset options from JSON file
|
42 |
with open("sentinel_datasets.json") as f:
|
43 |
data = json.load(f)
|
@@ -109,14 +100,18 @@ if st.button("Calculate Index"):
|
|
109 |
# Visualization Parameters for Index Layers
|
110 |
vis_params = {"min": 0, "max": 1, "palette": ["blue", "white", "green"]}
|
111 |
|
112 |
-
#
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
|
|
|
|
|
|
|
|
121 |
except ee.EEException as e:
|
122 |
st.error(f"Earth Engine Error: {e}")
|
|
|
3 |
import ee
|
4 |
import geemap
|
5 |
import os
|
6 |
+
import time # For simulating delay during map loading
|
7 |
|
8 |
st.set_page_config(layout="wide")
|
9 |
+
|
10 |
+
# Custom styling for the button
|
11 |
m = st.markdown(
|
12 |
"""
|
13 |
+
<style>
|
14 |
+
div.stButton > button:first-child {
|
15 |
+
background-color: #006400;
|
16 |
+
color:#ffffff;
|
17 |
+
}
|
18 |
+
</style>""",
|
19 |
unsafe_allow_html=True,
|
20 |
)
|
21 |
|
|
|
29 |
|
30 |
ee.Initialize(project='ee-yashsacisro24')
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
# Load Sentinel dataset options from JSON file
|
33 |
with open("sentinel_datasets.json") as f:
|
34 |
data = json.load(f)
|
|
|
100 |
# Visualization Parameters for Index Layers
|
101 |
vis_params = {"min": 0, "max": 1, "palette": ["blue", "white", "green"]}
|
102 |
|
103 |
+
# Add loading spinner while the map is loading
|
104 |
+
with st.spinner('Loading the map, please wait...'):
|
105 |
+
time.sleep(2) # Simulate processing delay (you can adjust/remove this in production)
|
106 |
+
|
107 |
+
# If an index image is generated, add it to the map
|
108 |
+
if result_image:
|
109 |
+
Map = geemap.Map()
|
110 |
+
Map.setCenter(-100.0, 40.0, 4) # Adjusted for example
|
111 |
+
Map.addLayer(result_image, vis_params, index_choice)
|
112 |
+
Map.to_streamlit(height=600)
|
113 |
+
else:
|
114 |
+
st.warning("Result image not generated; check parameters.")
|
115 |
+
|
116 |
except ee.EEException as e:
|
117 |
st.error(f"Earth Engine Error: {e}")
|