Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -266,7 +266,7 @@ def preprocess_collection(collection, pixel_cloud_threshold):
|
|
266 |
return collection
|
267 |
|
268 |
# Process single geometry
|
269 |
-
def process_single_geometry(row, start_date_str, end_date_str, dataset_id, selected_bands, reducer_choice, shape_type, aggregation_period, custom_formula, original_lat_col, original_lon_col, kernel_size=None, include_boundary=None, user_scale=None):
|
270 |
if shape_type.lower() == "point":
|
271 |
latitude = row.get('latitude')
|
272 |
longitude = row.get('longitude')
|
@@ -291,10 +291,18 @@ def process_single_geometry(row, start_date_str, end_date_str, dataset_id, selec
|
|
291 |
except ValueError:
|
292 |
return None
|
293 |
|
|
|
294 |
collection = ee.ImageCollection(dataset_id) \
|
295 |
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
296 |
.filterBounds(roi)
|
297 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
if aggregation_period.lower() == 'custom (start date to end date)':
|
299 |
collection = aggregate_data_custom(collection)
|
300 |
elif aggregation_period.lower() == 'daily':
|
@@ -375,7 +383,7 @@ def process_aggregation(locations_df, start_date_str, end_date_str, dataset_id,
|
|
375 |
st.write(f"Original Collection Size: {raw_collection.size().getInfo()}")
|
376 |
|
377 |
if tile_cloud_threshold > 0 or pixel_cloud_threshold > 0:
|
378 |
-
raw_collection = preprocess_collection(raw_collection,
|
379 |
st.write(f"Preprocessed Collection Size: {raw_collection.size().getInfo()}")
|
380 |
|
381 |
with ThreadPoolExecutor(max_workers=10) as executor:
|
|
|
266 |
return collection
|
267 |
|
268 |
# Process single geometry
|
269 |
+
def process_single_geometry(row, start_date_str, end_date_str, dataset_id, selected_bands, reducer_choice, shape_type, aggregation_period, custom_formula, original_lat_col, original_lon_col, kernel_size=None, include_boundary=None, user_scale=None, pixel_cloud_threshold=0):
|
270 |
if shape_type.lower() == "point":
|
271 |
latitude = row.get('latitude')
|
272 |
longitude = row.get('longitude')
|
|
|
291 |
except ValueError:
|
292 |
return None
|
293 |
|
294 |
+
# Filter collection by date and area first
|
295 |
collection = ee.ImageCollection(dataset_id) \
|
296 |
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
297 |
.filterBounds(roi)
|
298 |
|
299 |
+
st.write(f"After initial filtering: {collection.size().getInfo()} images")
|
300 |
+
|
301 |
+
# Apply pixel cloud masking if threshold > 0
|
302 |
+
if pixel_cloud_threshold > 0:
|
303 |
+
collection = preprocess_collection(collection, pixel_cloud_threshold)
|
304 |
+
st.write(f"After cloud masking: {collection.size().getInfo()} images")
|
305 |
+
|
306 |
if aggregation_period.lower() == 'custom (start date to end date)':
|
307 |
collection = aggregate_data_custom(collection)
|
308 |
elif aggregation_period.lower() == 'daily':
|
|
|
383 |
st.write(f"Original Collection Size: {raw_collection.size().getInfo()}")
|
384 |
|
385 |
if tile_cloud_threshold > 0 or pixel_cloud_threshold > 0:
|
386 |
+
raw_collection = preprocess_collection(raw_collection, pixel_cloud_threshold)
|
387 |
st.write(f"Preprocessed Collection Size: {raw_collection.size().getInfo()}")
|
388 |
|
389 |
with ThreadPoolExecutor(max_workers=10) as executor:
|