0

I'm trying to obtain the cloud cover percentage of my ROI in a specific time interval using Sentinel-2.

//Sentinel collection
var sentinel2 = ee.ImageCollection("COPERNICUS/S2")
.filterBounds(ROI)
.filterDate('2017-06-01','2018-06-01');

//Add a cloud cover band
var cloud = function(sentinel2) {
return sentinel2.addBands(sentinel2.metadata('CLOUD_COVERAGE_ASSESSMENT')); };
print(sentinel2.map(cloud));

var getCloudScores = function(sentinel2){
var value = ee.Image(sentinel2).get('CLOUD_COVERAGE_ASSESSMENT');
return ee.Feature(null, {'score': value})
};

var s2 = sentinel2.filterBounds(ROI);
var results = s2.map(getCloudScores);
var chart = ui.Chart.feature.byFeature(results)
    .setChartType('LineChart')
    .setOptions({
      title: 'Cloud cover',
      hAxis: {
        title: 'Date',},
      vAxis: {
        title: 'Clouds'
      },
      lineWidth: 1,
      pointSize: 0
});

print(chart);

So far this code has worked, but I was wondering if there is another way to get it?

1 Answer 1

1

You can use the image collection as it is, and chart the CLOUD_COVERAGE_ASSESSMENT property directly:

var ROI = Map.getBounds(true)

var sentinel2 = ee.ImageCollection("COPERNICUS/S2")
.filterBounds(ROI)
.filterDate('2017-06-01','2018-06-01')

var chart = ui.Chart.feature.byFeature({
    features: sentinel2, 
    yProperties: ['CLOUD_COVERAGE_ASSESSMENT']
  })
  .setChartType('LineChart')
  .setOptions({
    title: 'Cloud cover',
    hAxis: {title: 'Date'},
    vAxis: {title: 'Clouds'},
    lineWidth: 1,
    pointSize: 0
  })

print(chart)

https://code.earthengine.google.com/e8cfe7fd4bef84bdacc11a6c9ab22afb

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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