I want to apply cloud masking to a MDNWI image but I get the error message "s2SR.map is not a function". I don't know how to resolve it.
var geometry=ee.Geometry.Polygon([[41.55427215633343,41.57962485896675],
[41.607143860434995,41.57962485896675],
[41.607143860434995,41.62429558047125],
[41.55427215633343,41.62429558047125],
[41.55427215633343,41.57962485896675]]);
var s2SR = ee.ImageCollection('COPERNICUS/S2_SR')
//filter start and end date
.filter(ee.Filter.calendarRange(2018,2018,'year'))
.filter(ee.Filter.calendarRange(9,10,'month'))
//filter according to drawn boundary
.filterBounds(geometry)
.filterMetadata('CLOUD_COVERAGE_ASSESSMENT', 'less_than',1)
.mean();
//print(typeof(s2SR))
//print("s2SR", s2SR);
//Map.addLayer(s2SR, {bands: ['B4', 'B3', 'B2'], min: 0, max: 2000}, 'Sentinel ');
Map.centerObject(geometry,10)
var Green = s2SR.select("B3");
var SWIR = s2SR.select("B11");
var mndwi = Green.subtract(SWIR).divide(Green.add(SWIR)).rename('MNDWI');
//Map.addLayer(mndwi, {min:0, max:1}, 'mndwı');
///// Cloud
var S2maskedVeg = function(image) {
var MNDWI = image.select(['MNDWI']);
return image.addBands(ee.Image(1).updateMask(mndwi.gte(0.95)).rename('MNDVI_mask'));
};
var S2collection = s2SR.map(mndwi).map(S2maskedVeg)
Map.addLayer(S2collection,{}, 'S2 NDWI mask');
(https://code.earthengine.google.com/6835ca74e985d40df906681039358ee1)