YashMK89 commited on
Commit
13c20d0
·
verified ·
1 Parent(s): 7fe59b4

update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -3
app.py CHANGED
@@ -220,23 +220,28 @@ if file_upload:
220
  result = calculate_custom_formula(image, roi, custom_formula)
221
 
222
  if result:
 
223
  calculated_value = result.getInfo()
224
- st.write(f"Result for {location_name}: {calculated_value}")
 
225
 
226
  # Store the result in session state
227
  st.session_state.results.append({
228
  'Location Name': location_name,
229
  'Latitude': latitude,
230
  'Longitude': longitude,
231
- 'Calculated Value': calculated_value # Store only the numeric value
232
  })
233
 
 
 
 
234
  # Convert results to DataFrame for download
235
  if st.session_state.results:
236
  result_df = pd.DataFrame(st.session_state.results)
237
  st.download_button(
238
  label="Download results as CSV",
239
  data=result_df.to_csv(index=False).encode('utf-8'),
240
- file_name='calculated_index_result.csv',
241
  mime='text/csv'
242
  )
 
220
  result = calculate_custom_formula(image, roi, custom_formula)
221
 
222
  if result:
223
+ # Extract just the numeric value, not the dictionary with 'NDVI' label
224
  calculated_value = result.getInfo()
225
+ # Display the result as a numeric value, not as a dictionary
226
+ st.write(f"Result for {location_name}: {calculated_value['NDVI'] if 'NDVI' in calculated_value else calculated_value}")
227
 
228
  # Store the result in session state
229
  st.session_state.results.append({
230
  'Location Name': location_name,
231
  'Latitude': latitude,
232
  'Longitude': longitude,
233
+ 'Calculated Value': calculated_value['NDVI'] if 'NDVI' in calculated_value else calculated_value # Only store the numeric value
234
  })
235
 
236
+ # Generate the dynamic filename
237
+ filename = f"{main_selection}_{sub_selection}_{start_date.strftime('%Y/%m/%d')}_{end_date.strftime('%Y/%m/%d')}_{shape_type}.csv"
238
+
239
  # Convert results to DataFrame for download
240
  if st.session_state.results:
241
  result_df = pd.DataFrame(st.session_state.results)
242
  st.download_button(
243
  label="Download results as CSV",
244
  data=result_df.to_csv(index=False).encode('utf-8'),
245
+ file_name=filename,
246
  mime='text/csv'
247
  )