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")

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

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)
      title: 'Cloud cover',
      hAxis: {
        title: 'Date',},
      vAxis: {
        title: 'Clouds'
      lineWidth: 1,
      pointSize: 0


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

1 Answer 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")

var chart = ui.Chart.feature.byFeature({
    features: sentinel2, 
    title: 'Cloud cover',
    hAxis: {title: 'Date'},
    vAxis: {title: 'Clouds'},
    lineWidth: 1,
    pointSize: 0



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.