Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -292,16 +292,17 @@ def process_single_geometry(row, start_date_str, end_date_str, dataset_id, selec
|
|
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 |
-
|
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)
|
@@ -377,14 +378,38 @@ def process_aggregation(locations_df, start_date_str, end_date_str, dataset_id,
|
|
377 |
progress_text = st.empty()
|
378 |
start_time = time.time()
|
379 |
|
380 |
-
|
381 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
382 |
|
383 |
st.write(f"Original Collection Size: {raw_collection.size().getInfo()}")
|
|
|
|
|
384 |
|
385 |
-
if
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
386 |
raw_collection = preprocess_collection(raw_collection, pixel_cloud_threshold)
|
387 |
-
st.write(f"
|
388 |
|
389 |
with ThreadPoolExecutor(max_workers=10) as executor:
|
390 |
futures = []
|
|
|
292 |
return None
|
293 |
|
294 |
# Filter collection by date and area first
|
295 |
+
# Apply spatial filtering
|
296 |
collection = ee.ImageCollection(dataset_id) \
|
297 |
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
298 |
.filterBounds(roi)
|
299 |
|
300 |
+
# Apply cloud filtering if applicable
|
|
|
|
|
301 |
if pixel_cloud_threshold > 0:
|
302 |
collection = preprocess_collection(collection, pixel_cloud_threshold)
|
303 |
st.write(f"After cloud masking: {collection.size().getInfo()} images")
|
304 |
+
|
305 |
+
st.write(f"After initial filtering: {collection.size().getInfo()} images")
|
306 |
|
307 |
if aggregation_period.lower() == 'custom (start date to end date)':
|
308 |
collection = aggregate_data_custom(collection)
|
|
|
378 |
progress_text = st.empty()
|
379 |
start_time = time.time()
|
380 |
|
381 |
+
# Apply spatial filtering
|
382 |
+
if roi is not None:
|
383 |
+
raw_collection = ee.ImageCollection(dataset_id) \
|
384 |
+
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
385 |
+
.filterBounds(roi)
|
386 |
+
else:
|
387 |
+
raw_collection = ee.ImageCollection(dataset_id) \
|
388 |
+
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str))
|
389 |
|
390 |
st.write(f"Original Collection Size: {raw_collection.size().getInfo()}")
|
391 |
+
st.write(f"Original Collection Size: {ee.ImageCollection(dataset_id).filterDate(ee.Date(start_date_str), ee.Date(end_date_str)).size().getInfo()}")
|
392 |
+
st.write(f"Filtered Collection Size (After Spatial Filtering): {raw_collection.size().getInfo()}")
|
393 |
|
394 |
+
if pixel_cloud_threshold > 0:
|
395 |
+
raw_collection = preprocess_collection(raw_collection, pixel_cloud_threshold)
|
396 |
+
st.write(f"Filtered Collection Size (After Cloud Masking): {raw_collection.size().getInfo()}")
|
397 |
+
|
398 |
+
# if tile_cloud_threshold > 0 or pixel_cloud_threshold > 0:
|
399 |
+
# raw_collection = preprocess_collection(raw_collection, pixel_cloud_threshold)
|
400 |
+
# st.write(f"Preprocessed Collection Size: {raw_collection.size().getInfo()}")
|
401 |
+
# Apply cloud filtering
|
402 |
+
if imagery_base == "Sentinel" and "Sentinel-2" in sub_options[sub_selection]:
|
403 |
+
pixel_cloud_threshold = st.slider(
|
404 |
+
"Select Maximum Pixel-Based Cloud Coverage Threshold (%)",
|
405 |
+
min_value=0,
|
406 |
+
max_value=100,
|
407 |
+
value=5,
|
408 |
+
step=5,
|
409 |
+
help="Individual pixels with cloud coverage exceeding this threshold will be masked."
|
410 |
+
)
|
411 |
raw_collection = preprocess_collection(raw_collection, pixel_cloud_threshold)
|
412 |
+
st.write(f"Filtered Collection Size (After Cloud Masking): {raw_collection.size().getInfo()}")
|
413 |
|
414 |
with ThreadPoolExecutor(max_workers=10) as executor:
|
415 |
futures = []
|