The concept is just fine, but there are quite a few errors in the script.
This should work:
var R_443_560=B01/B03
var R_490_560=B02/B03
var MBR=Math.log10(Math.max(R_443_560,R_490_560))
var NDWI=(B03-B08)/(B03+B08)
var MedOC3=0
if (NDWI>=0) {
MedOC3=Math.pow(10,(0.38-3.688*MBR+1.036*MBR*2+1.616*MBR*3+1.328*MBR*4))
}
return [MedOC3]
Thanks for your reply. Is it possible to have NaN value where NDWI<0 instead of zero?
Also i would like to use a visualization for the MedOC3 variable such as ColorGradientVisualizer.createBlueRed(minVal, maxVal) how i can do that?
Thanks in adavance.
GeoTiff or JPG/PNG formats do not work well with NaN as far as I know.
If you are looking for transparency, I suggest you check this FAQ:
https://www.sentinel-hub.com/faq/how-can-i-make-some-pixels-transparent
For blue/red you can do something along these lines (configuring min/max appropriately):
var R_443_560=B01/B03
var R_490_560=B02/B03
var MBR=Math.log10(Math.max(R_443_560,R_490_560))
var NDWI=(B03-B08)/(B03+B08)
var MedOC3=0
if (NDWI>=0) {
MedOC3=Math.pow(10,(0.38-3.688*MBR+1.036*MBR*2+1.616*MBR*3+1.328*MBR*4))
}
let minVal = 0;
let maxVal = 10.0;
let viz = ColorGradientVisualizer.createBlueRed();
return viz.process(MedOC3);
Thank you for your answers. Is it possible to use a visualizer such as ColorGradientVisualizer.createWhiteGreen() but use logarithmic scale instead of linear?