I have a collection of Landsat images filtered over forest regions of India over a time interval of 6 years(2013 - 2018). I have again filtered this collection such that I have one image per 4 months, that is I have filtered on a quarterly basis so that I will have 3 images per year.
Now, for a particular point, there will be 18 pixels representing it over 6 years. I have to find, out of these 18 pixels, how many satisfy the condition - NDVI < 0.25. Suppose, 10 pixels satisfy this condition, then in my output image, the pixel representing that particular point should have its value = 10. Like this I have to do for all the points in my selected region.
I have no idea as to how to do this pixel wise computation. Can somebody help me on this?
In my code, I have done till filtering quarterly wise.
// FILTERING OUT FOREST COVER IN INDIA
var treeCanopyCover = hansen.clip(india).select('treecover2000');
var greater25 = treeCanopyCover.gte(25);
// NDVI FUNCTION
function addNDVI(image) {
var ndvi = image.normalizedDifference(['B5', 'B4']).rename('NDVI');
return image.addBands(ndvi);
}
// FILTERING THE COLLECTION
var startDate = ee.Date('2013-01-01');
var endDate = ee.Date('2019-06-30');
var filtered = l8.filterBounds(india)
.filterDate(startDate, endDate)
.filterMetadata('CLOUD_COVER','less_than',25)
.map(addNDVI);
var maskedCollection = filtered.map(function(image){
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)
var end = start.advance(3, 'month');
var filt = maskedCollection.filterDate(start,end).mean();
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();
var z = ee.ImageCollection(quarterlyimages);