I am trying to segment the images based on the threshold values. For instance, I want to put a threshold range between > 800 and < 1200, but with my existing code in Google Earth Engine, I can put the only one function at a time that is greater than, below is my code, how to define greater than and less than at the same time.

 // Threshold the thermal band to set hot pixels as value 1, mask all else.
var hotspots = s2a.gt(3500) // i want put here both grater than and less than function

// Display the thermal hotspots on the Map.
Map.addLayer(hotspots, {palette: 'FF0000'}, 'Hotspots');

1 Answer 1


Use the updateMask() function:

var hotspots = s2a.updateMask(s2a.gt(800)).updateMask(s2a.lt(1200))
        // set all values to 1 (instead of keeping the original values)
        // rename the band

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.