0

Please, how do get positive values of NDVI for my study area? Please see my Javascript code below. Unfortunately, after running the code, the NDVI chart generated are mostly negative. (See image attached). How do I correct this please?

Image of generated NDVI chart

See my Javascript code:

 var startDate = '2001-01-01'
    var endDate = '2020-12-31'

var images = landsat7.filter(ee.Filter.date(startDate, endDate));
print(images);

var ndvi = function(image){
  
  var ndv = image.normalizedDifference(['B4', 'B3']);
  // for Sentinel, use var scaled = image.normalizedDifference(['SR_B4', 'SR_B3']);
  return ndv.copyProperties(image, ['system:index', 'system:time_start'])
}

var ndvi = images.map(ndvi)

print(ndvi);

var nd = ndvi.max().clip(finni);

Map.addLayer(nd, {min:0,max:1,palette:['white', 'Green']}, 'NDVI');

var chart = ui.Chart.image.seriesByRegion({
  imageCollection:ndvi,
  regions:finni,
  reducer: ee.Reducer.mean(),
  scale:30,
  
});

print(chart);
  • Have you filtered out clouds? – Jesse Anderson Nov 09 '22 at 23:08
  • I'm sorry. I really don't know how to filter clouds since I'm really new to this. What would you recommend please? – Kelechi Igwe Nov 11 '22 at 00:09
  • You have examples of a lot of common use-cases in the `Examples` section in the code editor, at the button on the `Scripts`tab. Look at this for instance: https://code.earthengine.google.com/2e934ecbf50ef6e8d69853e25c87721c – Daniel Wiell Nov 22 '22 at 09:12

0 Answers0