1

I've written a function to compute the percentage of clouds+shadows+snow for a particular region and add this percentage as a new image property called CLOUD_COVER_R. The main objective is to filter the new collection based on that property. Here is the code of the function (I'm working in the GEE Python API):

def add_cloudCover(img):
    # Bit 0 - Fill
    # Bit 1 - Dilated Cloud
    # Bit 2 - Cirrus (high confidence)
    # Bit 3 - Cloud
    # Bit 4 - Cloud Shadow
    # Bit 5 - Snow
    qa = img.select('QA_PIXEL').clip(region)
    unmasked = qa.gt(0)
    unmasked_area = unmasked.multiply(ee.Image.pixelArea())
    mask = qa.bitwiseAnd(int('111000', 2)).eq(0)
    masked_area = mask.multiply(ee.Image.pixelArea())
    u_area = unmasked_area.reduceRegion(
        reducer=ee.Reducer.sum(),
        geometry=region,
        scale=30,
        maxPixels=1e10
    )
    area = masked_area.reduceRegion(
        reducer=ee.Reducer.sum(),
        geometry=region,
        scale=30,
        maxPixels=1e10
    )
    landCover = ee.Number(area.get('QA_PIXEL')).multiply(100).divide(ee.Number(u_area.get('QA_PIXEL')))
    cloudCover = ee.Number(100).subtract(landCover).round()
    return img.set('CLOUD_COVER_R', cloudCover)

The function seems to work properly but when I filter the imagecollection by the CLOUD_COVER_R property I can not get the info (getInfo()) of the collection which I've tried by:

Landsat_CC30 = Landsat.filter(ee.Filter.lt('CLOUD_COVER_R', 30))
image_props = geemap.image_props(Landsat_CC30 .first())
image_props.getInfo()

Moreover, I can filter the collection by any other metadata property but when I filter by the new property I can do nothing with the collection.

1
  • The code you shared is not sufficient to make the example reproducible. Please share the additional code where you map the function to the complete collection. Mar 26 at 17:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.