I am pretty new to GEE.
My task is to get all Sentinel 2 images from a specific time. Then I want to filter this collection by a maximum cloud coverage over an area of interest, which is imported before as a shapefile. I use this Image Collection later to calculate and export the maximum NDVI.
I know how to filter Cloud Percentage over the whole scene, but as I need only a small AOI too many images get filtered. So my Problem is to not filter the cloud probability over the whole scene, but just over the small polygon (AOI).
I am working currently in Python with geemap and the ee library.
import ee
import geemap
ee.Initialize()
ee.Authenticate()
def calculateNDVI(image):
result = image.normalizedDifference(["B8","B4"]).rename("ndvi")
return image.addBands(result)
geometry = #"Imported Polygon"#
sentinel = ee.ImageCollection("COPERNICUS/S2_SR").filterDate(
"2020-04-01","2021-10-01").filterBounds(geometry).filter(
ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE',10))
ndvi = sentinel.map(calculateNDVI)
maxNDVI = ndvi.max()
geemap.ee_export_image(maxNDVI,
filename= maxNDVI.tif,
scale = 10, region = geometry, file_per_band=False,
crs = 'EPSG:3035')