0

I'm trying to apply thresholding on MODIS NDSI. My goal is the Yearly NDSI images. For both Yearly and Monthly images, NDSI should move between -1 to 1, considering as a threshold value of 0.1, we should end having values between 0.1 to 1. But I'm not able to do it or I'm doing something wrong in my code.

var dataCollection = ee.ImageCollection('MODIS/006/MOD10A1')

var maskedW21 = function(image) {
  var NDSI = dataCollection.select(['NDSI_Snow_Cover']);
  var maskNDSI = NDSI.lte(1).and(NDSI.gte(0.1));

  
  var mask = maskNDSI.updateMask(maskNDSI)
  .rename('mask');
  return image.addBands(mask)
  .updateMask(mask);
};

1 Answer 1

1

I am assuming you want to map the maskedW21 to the dataCollection. The only changes I made to the original script was changing dataCollection to èe.Image(image), removing an extra updateMask and changing the threshold values. If you consult the bands' information of the collection, the 'NDSI_Snow_Cover' band takes values from 0 to 100, so I assumed that this is in a percentage scale and this transformed 1 to 100 and 0.1 to 10.

var maskedW21 = function(image) {
  var NDSI = ee.Image(image).select(['NDSI_Snow_Cover']);
  var maskNDSI = NDSI.lte(100).and(NDSI.gte(10));
  
  var mask = NDSI.updateMask(maskNDSI)
                 .rename('mask');
  return image.addBands(mask)
};

var resul = dataCollection.map(maskedW21);

// Check first image
Map.addLayer(resul.first(), {bands: 'mask'}, 'mask')
2
  • But I want to get collection in range of 0.1 to 1 so that I can take monthly mean for all yearly images Sep 3, 2022 at 8:00
  • You can just divide NDSI by 100 using NDSI.divide(100) and then change the thresholds used to define the maskNDSI to 1 and 0.1. Jan 3, 2023 at 5:27

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.