Below is the link of my code to calculate EVI in Google Earth engine. It is not giving/rendering color according to the color palette! Please help me in this regard. https://code.earthengine.google.com/995504963211f6c4d300ac364dc6697c

function maskS2clouds(image) {

  var qa = image.select('QA60');

  var cloudBitMask = ee.Number(2).pow(10).int();
  var cirrusBitMask = ee.Number(2).pow(11).int();

  var mask = qa.bitwiseAnd(cloudBitMask).eq(0).and(
  return image.updateMask(mask).divide(10000);

var composite = s2.filterDate('2018-03-01', '2018-03-15')
                  // Pre-filter to get less cloudy granules.
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 20))

Map.setCenter(87.32,22.40, 6);
Map.addLayer(composite, {bands: ['B6', 'B4', 'B3'], min: 0, max: 0.3},'fcc');

var landcover_roi = composite.clip(ft);
var evi =landcover_roi.expression(
    '2.5 * ((NIR-RED) / (NIR +6 * RED -7.5* BLUE))', {
Map.addLayer(ft, {}, 'From Fusion Table');

var EVI=evi.multiply(100).uint8()
var meanDictionary = EVI.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: ft.geometry(),
  scale: 20,
  maxPixels: 1e9


var palette = ['FFFFFF', 'CE7E45', 'DF923D', 'F1B555', 'FCD163', '99B718',
               '74A901', '66A000', '529400', '3E8601', '207401', '056201',
               '004C00', '023B01', '012E01', '011D01', '011301'];

// Center the map
Map.setCenter(87.32,22.40, 6);

 Map.addLayer(EVI,{min: -1, max: 1, palette: palette},'Sentinel-2 evi')
  description: 'evi',
  scale: 30,
 region: ft,
  • 1
    Please paste your code here. People will be more likely to help if the code is on site.
    – OverArch
    Sep 26, 2018 at 12:15

1 Answer 1


Your stritching values in Map.addLayer are for a float band type (-1 to 1), and are not really stretching much. To use float values you should not change the band's type to unsigned integer 16 bits. This would do it:

var EVI=evi//.multiply(100).uint16();

and the stretching values should be wider to represent the range of the output:

Map.addLayer(EVI,{min: -5, max: 4, palette: palette},'Sentinel-2 evi');

you can play around moving min and max

And if you want/need to change band's type, you should not use an unsigned integer as it not holds negative values, and also change the stretch values to adapt to it. Code:

var EVI = evi.multiply(10).toInt8();
Map.addLayer(EVI,{min: -50, max: 40, palette: palette},'Sentinel-2 evi');
// full stretch
// Map.addLayer(EVI,{min: -125, max: 125, palette: palette},'Sentinel-2 evi');

This is a good option for reducing the size of the output

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.