I want to classify crop types using Sentinel-2 image in GEE. Before starting the classification, however, I want to update the mask of the image, so that water, urban areas, forest and other non-arable land is masked. For that purpose I uploaded a shape file with the arable land and imported it as a FeatureCollection.

My question is is it possible to use this FeatureCollection to update the mask of the image dataset. I know of the updateMask() function but it takes an image as its argument.

1 Answer 1


You could do something like:

var ic = ee.ImageCollection('...')
var fc = ee.FeatureCollection('....')
var mask = ee.Image.constant(1).clip(fc.geometry()).mask().not()

ic = ic.map(function(image){return image.updateMask(mask)})

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.