Zeel commited on
Commit
566bbba
·
1 Parent(s): 13c538e

fix buttom button

Browse files
Files changed (1) hide show
  1. app.py +52 -10
app.py CHANGED
@@ -74,6 +74,16 @@ with st.expander("Advanced Controls", expanded=False):
74
 
75
  geometry_gdf = input_gdf[input_gdf.index == input_geometry_idx]
76
 
 
 
 
 
 
 
 
 
 
 
77
  m = leafmap.Map()
78
 
79
  st.markdown(
@@ -165,13 +175,45 @@ print(type(stats_df["Points"].item()))
165
  csv = stats_df.T.to_csv(index=True)
166
  st.download_button("Download Geometry Metrics", csv, f"{file_url}_metrics.csv", "text/csv", use_container_width=True)
167
 
168
- # Add HTML button to open in Google Earth
169
- st.markdown(
170
- f"""
171
- <div style="display: flex; justify-content: center;">
172
- <a href="https://huggingface.co/spaces/SustainabilityLabIITGN/NDVI_PERG?file_url={file_url}" target="_blank">
173
- <button>Click for NDVI Timeseries</button>
174
- </a>
175
- """,
176
- unsafe_allow_html=True,
177
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
 
75
  geometry_gdf = input_gdf[input_gdf.index == input_geometry_idx]
76
 
77
+
78
+ def check_valid_geometry(geometry_gdf):
79
+ geometry = geometry_gdf.geometry.item()
80
+ if geometry.type != "Polygon":
81
+ st.error(f"Selected geometry is of type '{geometry.type}'. Please provide a 'Polygon' geometry.")
82
+ st.stop()
83
+
84
+
85
+ check_valid_geometry(geometry_gdf)
86
+
87
  m = leafmap.Map()
88
 
89
  st.markdown(
 
175
  csv = stats_df.T.to_csv(index=True)
176
  st.download_button("Download Geometry Metrics", csv, f"{file_url}_metrics.csv", "text/csv", use_container_width=True)
177
 
178
+
179
+ if isinstance(file_url, str):
180
+ st.markdown(
181
+ f"""
182
+ <div style="display: flex; justify-content: center;">
183
+ <a href="https://huggingface.co/spaces/SustainabilityLabIITGN/NDVI_PERG?file_url={file_url}" target="_blank">
184
+ <button style="
185
+ background-color: #006400; /* Green background */
186
+ color: white; /* White text */
187
+ padding: 10px 20px;
188
+ font-size: 16px;
189
+ border: none;
190
+ border-radius: 5px;
191
+ cursor: pointer;
192
+ ">
193
+ Click for NDVI Timeseries
194
+ </button>
195
+ </a>
196
+ </div>
197
+ """,
198
+ unsafe_allow_html=True,
199
+ )
200
+ else:
201
+ st.markdown(
202
+ f"""
203
+ <div style="display: flex; justify-content: center;">
204
+ <button style="
205
+ background-color: #FF0000; /* Green background */
206
+ color: white; /* White text */
207
+ padding: 10px 20px;
208
+ font-size: 16px;
209
+ border: none;
210
+ border-radius: 5px;
211
+ cursor: pointer;
212
+ ">
213
+ Click for NDVI Timeseries (This button will be enabled when you provide a file via `?file_url=`)
214
+ </button>
215
+ </a>
216
+ </div>
217
+ """,
218
+ unsafe_allow_html=True,
219
+ )