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?