I want to define a function for an index MMRI using the formula given below
I'm relatively new to JS and I'm having trouble defining it correctly.
First, I defined NDVI and MNDWI. This works fine.
var addIndicesL5 = function(img) {
var ndvi = img.normalizedDifference(['B4','B3']).rename('NDVI');
var mndwi = img.normalizedDifference(['B2','B5']).rename('MNDWI');
return img
.addBands(ndvi)
.addBands(mndwi)
};
Then, I defined a separate function to get their absolute values using
var ndvi_mndwi_abs = function(img){
var ndvi_abs = (img.select('NDVI')).abs.rename('NDVI_ABS');
var mndwi_abs = (img.select('MNDWI')).abs.rename('MNDWI_ABS');
return img
.addBands(ndvi_abs)
.addBands(mndwi_abs);
};
(Following this, I plan to take the normalizedDifference of 'MNDWI_ABS' and 'NDVI_ABS' bands to get MMRI)
However, when I map ndvi_mndwi_abs function to the Image Collection, I get an error saying " img.select(...).abs.rename is not a function".
How can I rewrite this function?