I am now using Google Earth Engine to process the Landsat 8 images. Now I have calculated NDVI, EVI, mNDWI and generated some maps. I am now want to generate a function based on those indices values, output binary numbers (0 or 1) and layout binary image. But I get stuck, and I hope anybody could help me. I want to justify the water body, there's a formula:
water = 1 EVI < 0.1 and (mNDWI > EVI or mNDWI > NDVI)
water = 0 For other cases
The GEE guideline says the traditional if statement is not recommended and yes I tried it doesn't work, I used the way they suggested:
var water = ee.Algorithms.If(evi < 0.1 && (mndvi>evi || mndwi > ndvi), 1, 0);
var waterViz = {min: 0, max: 1, palette: ['00FFFF', '0000FF']};
Map.addLayer(water, waterViz, 'water', false);
And it says:"Cannot add an object of type ComputedObject to the map."
I have seen a similar question here, but that user used ArcGIS. I am new to JavaScript.