I had reclassified("Reclassify by table" in QGIS) the SWIR1 band value for a coastal erosion project to differentiate the land and the water better uisng QGIS and then replaced the SWIR1.tiff file in the bands directory. Then indexed without changing the MTL.txt, ANG.txt and the dataset documentation file(.yaml). The bands were downloaded from USGS. I tried to plot the Modified Normalized Difference Water Index(MNDWI) using the green band and swir1 using both rasterio and ODC(after indexing). Both gave me different results :

Using Rasterio : Using rasterio

Using ODC : From ODC

MNDWI calculated using the following lines of code : Rasterio :

mndwi = (green.astype('f4') - swir1.astype('f4'))/(green.astype('f4') + swir1.astype('f4'))


ds = ds.assign(MNDWI = lambda ds: (ds.green[0] - ds.swir1[0]) / (ds.green[0] + ds.swir1[0]))
ds.MNDWI.attrs = ds.green.attrs

What could be the reason for the difference in results? Could it be to do with the dataset documentation file and indexing?

  • Can you provide some more information about what you mean by "reclassified the SWIR1 band value"? e.g. what exact processing steps did you apply in QGIS, and did this change the output data type or nodata values etc? Commented Aug 31, 2021 at 10:55
  • I used the "Reclassify by table" tool under "Raster analysis" in the processing toolbox window in QGIS to change SWIR1 band values between 7000 and 8000, which was water mostly, to 500 and values above 12000 to 40000, which was land. Nodata values weren't changed, I'm not sure about the output data type as I didn't change anything except the changes mentioned above and then saved the output without changing the CRS or any other properties.
    – Qexpert
    Commented Aug 31, 2021 at 11:39


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.