update app.py
Browse files
app.py
CHANGED
@@ -177,13 +177,6 @@ def calculate_custom_formula(image, geometry, formula):
|
|
177 |
scale=30
|
178 |
)
|
179 |
|
180 |
-
# Function to mask clouds based on QA60 (Sentinel-2)
|
181 |
-
def mask_clouds(image, cloud_threshold):
|
182 |
-
# Cloud mask based on the QA60 band (sentinel-2)
|
183 |
-
qa60 = image.select(['QA60'])
|
184 |
-
cloud_mask = qa60.bitwiseAnd(1 << 10).eq(0)
|
185 |
-
return image.updateMask(cloud_mask).clip(image.geometry())
|
186 |
-
|
187 |
# Process each point or polygon
|
188 |
results = []
|
189 |
if locations_df is not None:
|
@@ -198,13 +191,10 @@ if locations_df is not None:
|
|
198 |
roi = ee.Geometry.Point([longitude, latitude])
|
199 |
|
200 |
# Load the image collection based on the user's selection
|
201 |
-
collection = ee.ImageCollection(
|
202 |
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
203 |
-
.filterBounds(roi)
|
204 |
-
|
205 |
-
# Apply cloud masking if the index is NDVI or NDWI
|
206 |
-
if index_choice in ['NDVI', 'NDWI'] and cloud_threshold is not None:
|
207 |
-
collection = collection.map(lambda image: mask_clouds(image, cloud_threshold))
|
208 |
|
209 |
# Check if the collection has images for the selected date range
|
210 |
image_count = collection.size().getInfo()
|
|
|
177 |
scale=30
|
178 |
)
|
179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
# Process each point or polygon
|
181 |
results = []
|
182 |
if locations_df is not None:
|
|
|
191 |
roi = ee.Geometry.Point([longitude, latitude])
|
192 |
|
193 |
# Load the image collection based on the user's selection
|
194 |
+
collection = ee.ImageCollection('COPERNICUS/S2') \
|
195 |
.filterDate(ee.Date(start_date_str), ee.Date(end_date_str)) \
|
196 |
+
.filterBounds(roi) \
|
197 |
+
.filter(ee.Filter.lt('system:cloud_coverage', cloud_threshold)) # Apply cloud coverage filter
|
|
|
|
|
|
|
198 |
|
199 |
# Check if the collection has images for the selected date range
|
200 |
image_count = collection.size().getInfo()
|