6

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.

TomazicM
  • 25,601
  • 22
  • 29
  • 39
ABC
  • 341
  • 3
  • 12

1 Answers1

10

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)})
Rodrigo E. Principe
  • 10,085
  • 1
  • 28
  • 35