I have a script that calculates number of pixels with NDVI values that are higher than 0.3, 0.5 and 0.7.
My code runs with no errors, but it get value 0 and doesn't really count.
what can be the reason?
var meanImage=ee.Image(byYear.get[0]);
var gt03 = meanImage.gt(0.3).selfMask().rename('NDVI_gt03');
var gt04 = meanImage.gt(0.5).selfMask().rename('NDVI_gt05');
var gt05 = meanImage.gt(0.7).selfMask().rename('NDVI_gt07');
Map.addLayer(gt03,NDVIcolor,'gt03');
Map.addLayer(gt04,NDVIcolor,'gt05');
Map.addLayer(gt05,NDVIcolor,'gt07');
//count the number of total pixels
var c03 = gt03.reduceRegion({
reducer: ee.Reducer.count(),
geometry: geometry,
crs: 'EPSG:4326',
scale: 30,
});
var c05 = gt05.reduceRegion({
reducer: ee.Reducer.count(),
geometry:geometry,
crs: 'EPSG:4326',
scale: 30,
});
var c07 = gt07.reduceRegion({
reducer: ee.Reducer.count(),
geometry:geometry,
crs: 'EPSG:4326',
scale: 30,
});
// print the dictionary output
print(c03,'Total Pixels gt 0.3 ');
print(c05,'Total Pixels gt 0.5 ');
print(c07,'Total Pixels gt 0.7 ');
I have tried also to use listOfImages but still got 0.
My end goal is to calculte the number of pixels with the given values for one image.
link for my code: https://code.earthengine.google.com/559d0922b50d67cf01e4d5b03a21666d