0

I have code that suppose to calculte NDVI and calssify it according to the NDVI value. I have tried to add a function that will create for me a new layer that will have only pixels with value higher than 0.3 but for some reason nothing happend.

This is my function:

//////try to create layers with the pixels in red
var PixelsCounLayers = listOfImages.map(function(img){
  var imageNDVI=image.select('NDVI');
  var grt03=imageNDVI.gt(0.3).selfMask().rename('0.3');
  var grt05=imageNDVI.gt(0.5).selfMask().rename('0.5');
  var grt07=imageNDVI.gt(0.7).selfMask().rename('0.7');

return image.set('grt03', grt03).set('grt05',grt05).set('grt07', grt07);
});

I have also tries another version:


for (var i in listOfNumbers){
  var imageNDVI=image.select('NDVI');
  var hotspot=imageNDVI.gt(0.3)
  .selfMask()
  .rename('hotspot03');
Map.addLayer(hotspot,{palette: 'FF0000'},i);}

But I have gotten error:

0: Layer error: Image.select: Pattern 'NDVI' did not match any bands.

and this is link to the full code: https://code.earthengine.google.com/f1b79ba01d16ebc343a35af8482f542d

I used the polygon of Osaka but you can use whatever polygon you want.

My end goal: to create and display new layer that contains only pixels with value higher than 0.3

1 Answer 1

0

I made it work with this code:


for (var i in listOfNumbers){
  var imageNDVI = ee.Image(listOfImages.get(listOfNumbers[i]));
  var hotspot=imageNDVI.gt(0.3)
  .selfMask()
  .rename('hotspot03');
Map.addLayer(hotspot,{palette: 'FF0000'},i);}

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.