Skip to main content
added 345 characters in body
Source Link
ReutKeller
  • 2.2k
  • 4
  • 37
  • 91

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/c2fd1ed0e17afd9bbdc26a208f0973b5https://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

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);
});

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

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

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

Source Link
ReutKeller
  • 2.2k
  • 4
  • 37
  • 91

Create Layer of pixels with value higher than 0.3

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);
});

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

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