I want to apply the following condition statement to all the pixels of an indices image having only 1 band. The condition is as follows-
For that first I have calculated the mean value of my image. Next I have printed the bands existing and then used the expression by substituting the band values.
var mean = MNDWI.reduceRegion(ee.Reducer.mean(),clip_layer,28);
print('mean', mean)
var band_names = MNDWI.bandNames();
print(band_names)
var index = MNDWI
var recode = ee.Image().expression(
'(mean > 0 and index >= mean) or ' +
'(mean <= 0 and index >= (mean**5 - 0.02)) ' +
'? 254 : 0', {
mean: mean,
index: index
})
Map.addLayer(recode)
Here (MNDWI) represents the index, and "B3" is the single band that index is having which can be observed in the print statement output.
But I am getting this error-
Layer error: Image.gt, argument 'image1': Invalid type. Expected type: Image. Actual type: Dictionary. Actual value: {B3=-0.14653535282222163}