I want to find the areas where the NDVI value were higher then 0.4 at the end of April and NDVI values were lower then 0.3 at the end of June. I have tried to make it using below demonstrated script, unfortunately it did not work out. Could you please assist me on improving the script below or suggest me another ways to do it.

var test = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR/")
                  .filterDate('2000-04-15', '2000-04-30')
                    .normalizedDifference(['B4', 'B3'])
                      .gt(0.4). and (
                  .filterDate('2000-07-15', '2000-07-30')
                    .normalizedDifference(['B4', 'B3'])

Here is an example of how to do that (https://code.earthengine.google.com/87afb1047d8737b6aa796aa7c6ca9da4):

var collection1 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR").filterBounds(point).filterDate('2000-04-15', '2000-04-30');
var image1 = collection1.mean();
var ndvi1 = image1.normalizedDifference(['B4', 'B3']).gt(0.4);

var collection2 = ee.ImageCollection("LANDSAT/LT05/C01/T1_SR").filterBounds(point).filterDate('2000-07-15', '2000-07-30');
var image2 = collection2.mean();
var ndvi2 = image2.normalizedDifference(['B4', 'B3']).lt(0.4);

var total = ndvi1.and(ndvi2);

Map.addLayer(ndvi1, {}, 'ndvi1');
Map.addLayer(ndvi2, {}, 'ndvi2');
Map.addLayer(total, {}, 'both');

The first two methods you use (filterBounds and filterDate) return an Image-Collection. The method normalizedDifference only works on an image. So you need to implement another step between the filtering and the calculation of the NDVI. You can either (1) reduce the image collection as is done in the example (e.g. using mean(), first(), median() etc.) or (2) calculate the NDVI for each image in the collection using map(), but then you'll still need to reduce those maps afterwards.

After calculating the NDVI, you can apply the gt() and lt() functions to create maps with ones and zeroes. And finally combine them using and() to select pixels that meet both of the criteria.

Furthermore, you might also consider to mask out clouded pixels before calculating the NDVI.

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.