# Finding whether a particular band value is consistently less over a period of time in an image collection

The code below gives me forest regions of India from the Hansen data set and then I have filtered the landsat images of these regions from 2013-2019 on a quarterly basis. My output image is such that each pixel has its value as the number of pixels with NDVI less than 0.25 at that particular pixel location over these years.

Let's suppose, in the output image, one of the pixel has a value = 6, that is, at that particular pixel location, there are 6 pixels over these years which had NDVI < 0.25. I have to find out whether these 6 pixels occurred consecutively or not. That is, I want to know whether NDVI was constantly low in the consecutive quarters and years. If that is the case, then I can conclude that region is under threat. I also want to know the time period when the NDVI was consistently low. Is there a way I can do this?

``````// FILTERING OUT FOREST COVER IN INDIA

var treeCanopyCover = hansen.clip(india).select('treecover2000');
var greater25 = treeCanopyCover.gte(25);

// NDVI FUNCTION

var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
}

// FILTERING THE COLLECTION

var startDate = ee.Date('2013-01-01');
var endDate = ee.Date('2019-06-30');

var filtered = l8.filterBounds(indiaforest2)
.filterDate(startDate, endDate)

//print(filtered);

var x = image.updateMask(greater25);   // filtering over forest regions
return x;
});

// filtering quarterly wise

var map_m = function(y)
{
var months = [1, 5, 9];
var filtered_col = months.map(function(m)
{
var start = ee.Date.fromYMD(y, m, 1)

return filt.set('year', y)
.set('month', m)
.set('system:time_start',ee.Date.fromYMD(y,m,1)) ;
});

return filtered_col;
};

var years = ee.List.sequence(2013, 2019);
var quarterlyimages = years.map(map_m).flatten();
print(quarterlyimages);

var z = ee.ImageCollection(quarterlyimages);

var nullimages = z.map(function(image)
{
return image.set('count', image.bandNames().length());
})
.filter(ee.Filter.eq('count', 13));

// counting no. of pixels with NDVI < 0.25

var NDVI_count = nullimages.select('NDVI')