I'm using the Jupyter Notebooks Python GEE API.

I'm using the basic sentinel 2 cloud cover algorithm, maskS2cloud, from the catalogue example. But it removes the metadata from my image collection that I need later. Is there a way around this?

import ee

def maskS2clouds(image):
    qa = image.select('QA60')

#    Bits 10 and 11 are clouds and cirrus, respectively.
    cloudBitMask = 1 << 10
    cirrusBitMask = 1 << 11

#   Both flags should be set to zero, indicating clear conditions.
    mask = qa.bitwiseAnd(cloudBitMask).eq(0).And(qa.bitwiseAnd(cirrusBitMask).eq(0))

    return image.updateMask(mask).divide(10000)

ic= ee.ImageCollection("COPERNICUS/S2")\
    .filterDate('2016-10-01', '2017-02-28')

ic_masked = ic.map(lambda x: maskS2clouds(x))

# prints all the expected metadata

# only has ['system:index', 'system:bands', 'system:band_names']

1 Answer 1


Many image manipulation operations in Earth Engine remove all properties. The principle is that it is impractical for Earth Engine to determine whether the operation makes the metadata incorrect (such as if it is a scale/offset parameter) or to decide what to do when two images with different metadata are being combined with some binary operator.

In order to restore the properties when you know it makes sense, you can use copyProperties:

return image.updateMask(mask).divide(10000).copyProperties(image)

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.