I tried to create a land composite for mangroves in my study area. The code works fine for creating land composite map using Landsat 8, and when i modify the code for Landsat 7 images, i encounter this error.
Here is my code.
var L7 = ee.ImageCollection("LANDSAT/LE07/C02/T1_L2");
var addIndicesL7 = function (img) {
var ndvi = img.normalizedDifference (['SR_B4, SR_B3']).rename ('NDVI');
var ndmi = img.normalizedDifference (['SR_B7, SR_B2']).rename ('NDMI');
var mndwi = img.normalizedDifference (['SR_B2, SR_B5']).rename ('MNDWI');
var sr = img.select (['SR_B4']).divide(img.select(['SR_B3'])).rename ('SR');
var ratio54 = img.select (['SR_B5']).divide(img.select(['SR_B4'])).rename ('R54');
var ratio35 = img.select (['SR_B3']).divide(img.select(['SR_B5'])).rename ('R35');
var gcvi = img.expression ('(NIR/GREEN)-1', {
'NIR':img.select ('SR_B4'),
'GREEN':img.select ('SR_B2')
}).rename ('GCVI');
return img
.addBands (ndvi)
.addBands (ndmi)
.addBands (mndwi)
.addBands (sr)
.addBands (ratio54)
.addBands (ratio35)
.addBands (gcvi);
};
var year = 2021;
var startDate = (year-1)+'-01-01';
var endDate = (year+1)+'-12-31';
var l7 = L7.filterDate(startDate,endDate)
.map(maskClouds)
.map(addIndicesL7);
var L7composite = l7
.median()
.clip(studysite);