I am trying to calculate average annual MSAVI2 point estimates, but I would like account for cloud cover in my analysis. I think this can be achieved by filtering my data to only include images with less than 10% cloud cover. I think can do this using the ee.Algorithms.Landsat.simpleComposite function, however when I apply the function to my filtered variable, I keep getting running the rest of my code which says that filtered.map is not a function.
My guess is that the simpleComposite function somehow changes the class of the filtered object, but I'm unsure how to correctly implement ee.Algorithms.Landsat.simpleComposite to only include images with less than 10% cloud cover.
var LS7 = ee.ImageCollection("LANDSAT/LE07/C02/T1"),
//filtering data
var filtered = LS7.filterDate('2016-01-01', '2016-12-31');
var filtered = ee.Algorithms.Landsat.simpleComposite({collection: filtered,asFloat:true})
// Map over the collection to produce the desired data as a collection.
var MSAVI2_collection = filtered.map(function (image) {
return image.expression(
'(2 * NIR + 1 - sqrt(pow((2 * NIR + 1), 2) - 8 * (NIR - RED)) ) / 2',
{
'NIR': image.select('B4'),
'RED': image.select('B3')
}
);
});
//take an average of all MSAVI2 Values.
var MSAVI2 = MSAVI2_collection.median();
//add the MSAVI2 layer
Map.addLayer(MSAVI2, {min: -0.15, max: 0.15}, 'MSAVI2');
The reason is that the output of
ee.Algorithms.Landsat.simpleCompositeis a simple image, not anImageCollectionee object (according to the function documentation), andee.Imagedoes not have amapmethod.To compute the MSAVI2 expression in a single image, follow this method: