i want to conduct supervised classification, but i intended to calculate NDVI, NDWI, and NDBI indices prio to classification using the code below;
Map.addLayer(hjrb);
var image = ee.ImageCollection("LANDSAT/LC08/C02/T1_L2")
.filterDate("2014-01-01", "2015-12-31")
.filterMetadata("CLOUD_COVER", "less_than", 1)
.filterBounds(hjrb)
.mean();
var visParamfalse = {bands: ["SR_B3","SR_B4","SR_B5"]};
Map.addLayer (image.clip(hjrb), visParamfalse, 'study2015');
Map.centerObject(hjrb, 8);
//indices
var addIndices = function(image){
var gndvi = image.normalizedDifference(['SR_B5', 'SR_B3']).rename(['gndvi']);
var ndbi = image.normalizedDifference(['SR_B5', 'SR_B4']).rename(['ndbi']);
var ndwi = image.normalizedDifference(['SR_B3', 'SR_B5']).rename(['ndwi']);
return image.addBands(gndvi).addBands(ndbi).addBands(ndwi);
};
var composite = addIndices (composite);
after running this code, i got this error "Cannot read property 'normalizedDifference' of undefined"
undefined" but i remove var composite = addIndices (composite);
the code runs successfully.
please kindly help me through.