I want to select a specific land cover type in a land cover map obtained from the GEE dataset. Because I know the corresponding hex colour code, I tried the colour code as a condition to filter the wanted land cover type as below.

dataset = ee.ImageCollection('AAFC/ACI')
crop2019 = dataset.filter(ee.Filter.date('2019-01-01', '2019-12-31')).\

I want to see only specific coloured areas from the below map.

enter image description here

But, an error message comes up.

'EEException: Expression does not evaluate to an image.'

So, could you let me know a good way to address this error message or select the specific land cover type based on the colour?

Please help me!!

1 Answer 1


There is a conceptual issue here. Colors that you see in the map represent values in the landcover band. For example, the color for water is 3333ff and the value of pixels that represent water have value 20. You cannot filter a collection using one color because the color is not an image property, one image can have different colors (values of landcover band).

To get a collection in which every image contains only the water pixels as a mask (1 water, 0 not water) you have to do the following:

dataset = ee.ImageCollection('AAFC/ACI')
water = dataset.map(lambda i: i.eq(20).rename('water'))

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.