0

I am doing a classification of forest and nonforest area using the random forest classifier. At the end of the process I am not getting the color separation, the classified image looks like this: enter image description here

It had to be separated in green and red color, I'm not sure what I am doing wrong. The final part of the code is:

var clasificador = ee.Classifier.smileRandomForest(10).train({ features: total_samples, classProperty: 'id', inputProperties: bands})

var classificacion = imagen_final.select(bands).classify(clasificador)

var classVis = { min: 0, max: 10, palette: ['00B200 ' ,'#ff0400'] };

Map.addLayer(classificacion, classVis)

But you can see the whole code here: https://code.earthengine.google.com/979e35d45e3aaca1e81da67c2bc40062

1

1 Answer 1

1

The problem is that your visualization parameters are wrong. You only have two classes and you are setting the min and max values to 0 and 10. Try this.

var classVis = {
  min: 1,
  max: 2,
  palette: ['00B200 ' ,'#ff0400']
};

The result now looks like the following:

enter image description here

1
  • Thank you so much, I wasn't aware of that! Mar 23, 2023 at 20:43

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.