I just perform a NDVI classification, and I want to know if I can plot or display the values of the NDVI in different ranges in the same image. For example, from 0.0 to 0.3 is 'blue', from 0.3 to 0.5 'green', etc.
Here is part of my code:
//cargar coleccion de landsat
///////////////////////////////////////////////////////////////
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
//geometry with the AOI
var roi = geometry;
//filtrar la imagen de acuerdo a la cobertura de nubes en el poligono
////////////////////////////////////////////////////////////////////
var l8f = l8.filterBounds(roi);
var withCloudiness = l8f.map(function(img_zone) {
var cloud = ee.Algorithms.Landsat.simpleCloudScore(img_zone).select('cloud');
var cloudiness = cloud.reduceRegion({
reducer: 'mean',
geometry: roi,
scale: 30,
});
return img_zone.set(cloudiness);
});
var filteredCollection = withCloudiness.filter(ee.Filter.lt('cloud', 10));
var image = ee.Image(filteredCollection.filterBounds(roi)
.filterDate('2017-03-30', '2017-07-30')
.sort('CLOUD_COVER')
.first());
var red = image.select('B4');
//infrarrojo cercano
var NIR = image.select('B5')
var nvdi = (NIR.subtract(red)).divide(NIR.add(red)).rename('NDVI');
var filtered_1 = nvdi.gt(0.3); // boolean (0,1) where nvdi > 0.3
var filtered_2 = nvdi.gt(0.5); // boolean (0,1) where nvdi > 0.5
var filtered_3 = nvdi.gt(0.7); // boolean (0,1) where nvdi > 0.7
var filtered_4 = nvdi.gt(0.8); // boolean (0,1) where nvdi > 0.8
var multiplied_1 = nvdi.multiply(filtered_1); // multiply to set <= 0.3 to 0
var multiplied_2 = nvdi.multiply(filtered_2); // multiply to set <= 0.5 to 0
var multiplied_3 = nvdi.multiply(filtered_3); // multiply to set <= 0.7 to 0
var multiplied_4 = nvdi.multiply(filtered_4); // multiply to set <= 0.8 to 0
Map.addLayer(multiplied,{min: -1, max: 1},'ndvi_rice_1'); // plot
I know that there are many ways of select range of values, i´m using less than [lt], greater than [gt].