update app.py
Browse files
app.py
CHANGED
@@ -515,21 +515,29 @@ def process_aggregation(locations_df, start_date_str, end_date_str, dataset_id,
|
|
515 |
st.error("Custom formula cannot be empty. Please provide a formula.")
|
516 |
return aggregated_results
|
517 |
|
518 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
519 |
try:
|
520 |
-
|
521 |
-
is_image = True
|
522 |
-
# Try to get the nominal scale from the dataset (default to 30m if unavailable)
|
523 |
-
try:
|
524 |
-
scale = dataset.projection().nominalScale().getInfo()
|
525 |
-
except:
|
526 |
-
scale = 30
|
527 |
-
st.warning(f"Could not determine nominal scale for {dataset_id}. Using default scale of 30m.")
|
528 |
except:
|
|
|
|
|
|
|
|
|
529 |
dataset = ee.ImageCollection(dataset_id)
|
530 |
is_image = False
|
531 |
-
scale = 30
|
532 |
-
|
|
|
|
|
|
|
533 |
total_steps = len(locations_df)
|
534 |
progress_bar = st.progress(0)
|
535 |
progress_text = st.empty()
|
|
|
515 |
st.error("Custom formula cannot be empty. Please provide a formula.")
|
516 |
return aggregated_results
|
517 |
|
518 |
+
# Initialize is_image and scale with default values
|
519 |
+
is_image = False # Default to False, will be updated based on dataset type
|
520 |
+
scale = 30 # Default scale, will be overridden for ee.Image if possible
|
521 |
+
|
522 |
+
# Check if dataset_id is an ee.Image or ee.ImageCollection
|
523 |
+
try:
|
524 |
+
dataset = ee.Image(dataset_id)
|
525 |
+
is_image = True
|
526 |
+
# Try to get the nominal scale from the dataset
|
527 |
try:
|
528 |
+
scale = dataset.projection().nominalScale().getInfo()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
529 |
except:
|
530 |
+
st.warning(f"Could not determine nominal scale for {dataset_id}. Using default scale of 30m.")
|
531 |
+
scale = 30
|
532 |
+
except:
|
533 |
+
try:
|
534 |
dataset = ee.ImageCollection(dataset_id)
|
535 |
is_image = False
|
536 |
+
scale = 30 # Default scale for ImageCollections
|
537 |
+
except Exception as e:
|
538 |
+
st.error(f"Invalid dataset ID '{dataset_id}': {str(e)}. Must be a valid ee.Image or ee.ImageCollection.")
|
539 |
+
return aggregated_results
|
540 |
+
|
541 |
total_steps = len(locations_df)
|
542 |
progress_bar = st.progress(0)
|
543 |
progress_text = st.empty()
|