Filter Sentinel-2 images base on cloud cover over a region of interest

by Camilo Lozano   Last Updated September 11, 2019 16:22 PM

I know that there are a lot of examples of how to mask clouds for sentiel-2 images, but what I want is sort the images over an area of interest without change anything of the image.

Applying a cloud mask in zones where there are to much clouds, changes dramatically the image (in this case in over Bogota-Colombia). And, in some cases it generates holes in the image. thats why i dont want to change anything about the image.

I am taking this code Filter Landsat images base on cloud cover over a region of interest as reference.

and here is how it will be with Sentinel-2 image.

//the parameter for sentiel-2 images for clouds is
var ic =ee.ImageCollection('COPERNICUS/S2');

// A polygon representing the roi.
// my_polygon es a random polygon over Bogota Colombia (very cloudy zone)
var geometry = my_poligon;

var c = ic.filterBounds(geometry);

var withCloudiness = {
  var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
  var cloudiness = cloud.reduceRegion({
    reducer: 'mean', 
    geometry: geometry, 
    scale: 30,
  return image.set(cloudiness);

var filteredCollection = withCloudiness.filter('cloud', 10));

//my image with less clouds over my zone of interest                   
var my_image = ee.Image(filteredCollection.filterBounds(centroid)
    .filterDate('2019-01-01', '2019-06-30')

Related Questions

Updated January 11, 2018 11:22 AM

Updated September 26, 2018 15:22 PM

Updated February 06, 2019 05:22 AM

Updated September 10, 2018 04:22 AM