I have a rather basic question regarding the reclassification of ImageCollections in GEE. When I want to reclass individual values, I use the remap function as follow

var my_reclass= function(image) {
  var myreclass = image.remap([10 ,12],[  0,   3], null, 'my reclass');    

What I would like to do though and I can not find any examples, is to use number limits for my reclassification


-1 thru 3 = 5

3.1 thru 8.2 = 1


How can I achieve this?


I think what you need is something like this:

var random = ee.Image.random()

var customRemap = function(image, lowerLimit, upperLimit, newValue) {
  var mask = image.gte(lowerLimit).and(image.lt(upperLimit))
  return image.where(mask, newValue)

// values from 0 to 0.5 will be 10, the rest will not change
var remaped = customRemap(random, 0, 0.5, 10) 

  • Thank you both. The solutions work but it easier for me to understand Rodrigo's one.
    – geo_dd
    Apr 2 '19 at 11:27

I would do it like this. Values below the first threshold will be 0, from the first to second threshold limit will then be 1, the second to third will be 2 and so on.

// make a random image (ranging form 0 - 1 automatically)
var randomImage = ee.Image.random();
// set some thresholds between which you want to remap
var limits = [0, 0.2, 0.4, 0.6, 0.8];
// reclassify
var reclassified = ee.ImageCollection.fromImages(ee.List(limits).map(function(limit){
  return randomImage.gt(ee.Number(limit));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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