# Cloud cover percentage in Google Earth Engine

I'm doing a project at my university about the Cloud cover percentage in determinate areas in the world. I'm completely new to Google Earth Engine and I'm struggling a lot trying to find a solution for this task. The main problem is how to obtain the percentage of cloudiness in a certain pixel of a list of images.

Here is just the beginning of the code, hope you could help.

//coordinates Pavia
var city = ee.Geometry.Point(9.15, 45.18);

//add point on the map
Map.addLayer(city);

//dates of interests
var start = ee.Date('2016-01-01');
var end = ee.Date('2017-01-01');

//image collection
var Pavia = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
.filterBounds(città)
.filterDate(start, end)
.sort('CLOUD_COVER', true);

• "percentage of cloudiness" as in: 1) How many cloud free observations are available for that pixel or 2) sub-pixel cloud cover for each image and pixel. – Kersten Apr 23 '18 at 10:40

## 1 Answer

You can check out this script and the docs

// A mapping from a common name to the sensor-specific bands.
var LC8_BANDS = ['B2',   'B3',    'B4',  'B5',  'B6',    'B7',    'B10'];
var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'swir2', 'temp'];

// Compute a cloud score.  This expects the input image to have the common
// band names: ["red", "blue", etc], so it can work across sensors.
var cloudScore = function(img) {
// A helper to apply an expression and linearly rescale the output.
var rescale = function(img, exp, thresholds) {
return img.expression(exp, {img: img})
.subtract(thresholds).divide(thresholds - thresholds);
};

// Compute several indicators of cloudyness and take the minimum of them.
var score = ee.Image(1.0);
// Clouds are reasonably bright in the blue band.
score = score.min(rescale(img, 'img.blue', [0.1, 0.3]));

// Clouds are reasonably bright in all visible bands.
score = score.min(rescale(img, 'img.red + img.green + img.blue', [0.2, 0.8]));

// Clouds are reasonably bright in all infrared bands.
score = score.min(
rescale(img, 'img.nir + img.swir1 + img.swir2', [0.3, 0.8]));

// Clouds are reasonably cool in temperature.
score = score.min(rescale(img, 'img.temp', [300, 290]));

// However, clouds are not snow.
var ndsi = img.normalizedDifference(['green', 'swir1']);
return score.min(rescale(ndsi, 'img', [0.8, 0.6]));
};

// Filter the TOA collection to a time-range and add the cloudscore band.
var collection = ee.ImageCollection('LC8_L1T_TOA')
.filterDate('2013-05-01', '2013-07-01')
.map(function(img) {
// Invert the cloudscore so 1 is least cloudy, and rename the band.
var score = cloudScore(img.select(LC8_BANDS, STD_NAMES));
score = ee.Image(1).subtract(score).select(, ['cloudscore']);
return img.addBands(score);
});