I'm working on creating an NDVI time series and I'm trying to filter out clouds over a specific region so I wont get huge gaps in the time series.
Is there a way to reduce the extent by cloud percent?
Part of the code:
var extent =
/* color: #44c239 */
/* displayProperties: [
{
"type": "rectangle"
}
] */
ee.Geometry.Polygon(
[[[35.66951628813774, 33.212344469176244],
[35.66951628813774, 33.18720738523013],
[35.69560881743462, 33.18720738523013],
[35.69560881743462, 33.212344469176244]]], null, false);
// Applies scaling factors for LS 457.
function applyScaleFactors457(image) {
var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
var thermalBand = image.select('ST_B6').multiply(0.00341802).add(149.0);
return image.addBands(opticalBands, null, true)
.addBands(thermalBand, null, true);
}
var startdate = '2000-08-01';
var enddate= '2021-08-01';
var LS7Collection = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2')
.filterBounds(extent)
.filterDate(startdate, enddate)
.map(applyScaleFactors457);
//filer clouds by region ????
var c = LS7Collection.filterBounds(extent);
var getQABits = function(image, start, end, newName) {
// Compute the bits we need to extract.
var pattern = 0;
for (var i = start; i <= end; i++) {
pattern += Math.pow(2, i);
}
// Return a single band image of the extracted QA bits, giving the band
// a new name.
return image.select([0], [newName])
.bitwiseAnd(pattern)
.rightShift(start);
};
var clouds = function(image) {
// Select the QA band.
var QA = image.select(['SR_CLOUD_QA']);
// Get the internal_cloud_algorithm_flag bit.
return getQABits(QA, 1,1, 'Clouds').eq(1);
};
var cloudper = function(image){
return image.reduceRegion({
reducer: ee.Reducer.mean(),
geometry: extent,
scale: 30,
maxPixels: 1e9
})};
//var LS7Collection = LS7Collection.filter(ee.Filter.lessThan(cloudper(c.map(clouds)), 10));
//print(LS7Collection);
my full code: https://code.earthengine.google.com/?accept_repo=users/tomcol/personal