I have coe in GEE that calcultes the NDVI in a given polygon, from 2000 (based on landsat 7) and 2019 (landsat 8) ,create for each one a layer with pixels that their NDVI value is higher than 0.3 and then subtract them from each other in order to detect change.

The problem is that when I run my code for some reason the result is that ther is no diffference and I believe I have problem in my code. I think mabybe GEE doesn't do the subtruction if the pixels are not on the same location so I always get that no change.

maybe it will be easier to understand from my code: https://code.earthengine.google.com/98102459e86cc67232896d226f19565b

Basically I have create to layers in a long process and in this specific line:

// Map.centerObject(geometry,10);
for (var i in listOfNumbers1){
  var imageNDVI1 = ee.Image(listOfImages.get(listOfNumbers[i]));
  var hot2019=imageNDVI1.gt(0.3)
Map.addLayer(hot2019,{palette: '0000ff'},'2019');}

and then I subtract the two layers (hot2000 and hot 2010) like this:

var difference=hot2019.subtract(hot2000);

Map.addLayer(difference,{min:-1, max:1 ,palette: ['ff3300', 'a3a375','009933']},'difference');

My end goal is to get new layer that will be calssified into 3 values: -1,0 and 1

*I thought maybe the reason it happened is because it doesn't have rectangle extent *Any polygon would work. I have checked Delhi and New Mexico

  • Please, try to recreate this problem with a minimal script. Right now, it's a lot of code, making it hard to help you. – Daniel Wiell Jan 1 at 19:52

I didn't follow all your steps, but I did notice one error when you add a map layer:

Map.addLayer(hot2019,{palette: '0000ff'},'2019');

When you have a palette with one single color, that's the color you will get on your map, no matter what value you have. In your case, you have three discrete values: -1, 1, 1, so you'd want to provide three colors in your palette.

This could maybe give you some ideas:


| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.