I am looking for percentage of cloud cover in my study region from landsat images. Here is the code I have got so far:

    def cloudcover(image):
        value = image.get("CLOUD_COVER_LAND")
        return image.addBands(value)

    collection = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2') \
    .map(cloudcover) \
    .select("CLOUD_COVER_LAND") \
    listOfPoints = ee.FeatureCollection(points)
    col_med = collection.median()
    #extract values
    geemap.extract_values_to_points(listOfPoints, col_med, out_csv, scale= 30, crs = 'EPSG:4326')

But I keep getting this error:

EEException: reduce.median: Error in map(ID=LC08_166053_20180115): Image.addBands: Parameter 'srcImg' is required.

2 Answers 2


When getting properties from an image of feature you typically have to cast it to the correct type before using it, or get it as the expected type directly:

value = image.getNumber("CLOUD_COVER_LAND")


value = ee.Number(image.get("CLOUD_COVER_LAND"))

  • After applying the suggestions, I get following error: EEException: reduce.median: Error in map(ID=LC08_166053_20180115): Image.select: Pattern 'CLOUD_COVER_LAND' did not match any bands.
    – coder_001
    Jul 28 at 20:04
  • 1
    Explicitly turn the cloud cover to an image and rename it: ee.Image(image.getNumber("CLOUD_COVER_LAND")).rename('CLOUD_COVER_LAND') Jul 29 at 13:32
  • I get this error: EEException: Expected a homogeneous image collection, but an image with an incompatible band was encountered. Mismatched type for band 'CLOUD_COVER_LAND'. This band might require an explicit cast. But as you also pointed out, I think explicitly renaming and defining the data type is the main cause of error. So, I modified your suggestion into following and no longer get the error: value = image.getNumber("CLOUD_COVER_LAND") and new_value = ee.Image(value).toDouble().rename('clouds')
    – coder_001
    Jul 30 at 8:48

So, basically explicitly renaming the value to a completely different string other than the original name and defining the data type helped

    def cloudscore (image):
        value = image.getNumber("CLOUD_COVER_LAND")
        new_value = ee.Image(value).toDouble().rename('clouds')
        return image.addBands(new_value)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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