MNDWI for lake water detection

Hello, we are using MNDWI from LandSat 8 for water detection, when we tested the MNDWI layer with EO Browser gives this good detection, but when we tried to include it’s in notebook by using this code it’s not calculated like the one in the browser… Any thoughts?

evalscript= """

//VERSION=3

function setup() {
  return {
    input: ["B01", "B02", "B03","B04", "B05", "B06","B07","BQA","dataMask"],
    output: [
               { id: "BANDS", bands: 4},
               { id: "CLM",bands: 1},
               {id:"MNDWI", bands: 1},
               {id:"dataMask", bands: 1}
            ]    
    }
  }

function evaluatePixel(sample) {

  return {
    BANDS: [sample.B04, sample.B03, sample.B02, sample.dataMask], 
    CLM: [decodeLs8Qa(sample.BQA).cloud],
    dataMask:[sample.dataMask],
    MNDWI: [(sample.B03-sample.B06)/(sample.B03+sample.B06)]
  }
}

"""

download_task = SentinelHubEvalscriptTask(
    features=[(FeatureType.MASK, 'dataMask', 'IS_DATA'), (FeatureType.MASK, 'CLM'),(FeatureType.DATA, 'BANDS'),(FeatureType.DATA, 'MNDWI')],
    data_collection=DataCollection.LANDSAT_OT_L1,
    resolution=20, 
    maxcc=0.2, 
    time_difference=dt.timedelta(hours=2),
    evalscript=evalscript, 
    config=config,
)

indice= NormalizedDifferenceIndexTask((FeatureType.DATA, 'BANDS'), (FeatureType.DATA, 'MNDWI'), (1, 3))


Arwa
cc @aghandour

Hi Arwa,

Thanks for the post. Are you using the exact same evalscript in your notebook as is used in the EO Browser application? In the screenshot you provide, the image looks very cloudy and this will certainly affect the effectiveness of any index that you are using to detect lake water so it might be worth trying to use a different date and acquisition that would give you better quality data.

1 Like

Thank you, I modified the script to be exact as the one in Eo Brower but it’s still give same output…

This right, The rest of the image it’s better but what we are trying to do is to get the time-series of LandSat maybe this one can be neglected…

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.