Following on from a previous question (NDVI reclassify with mean +1SD as threshold in Google Earth Engine) I have managed to show the pixels that have value higher than NDVI mean+1SD at the estuary area on the map, which also overlap with the vegetation area. But I do notice the coloured regions are not universally black, which means I failed to do NDVI reclassify. I meant to use NDVI mean +1SD as a minimum threshold for reclassification, above the threshold to value 1 reclassify as 1 and below the threshold to value -1 reclassify as 0. The purpose of doing ndvi reclassify is :1. test if the pixels above the threshold overlap with the estuary vegetation area (which I have achieved); 2. count total number of pixels above and below the threshold. The code I have used:

var mean = ee.Number(stats.get('nd_mean'))
var std = ee.Number(stats.get('nd_stdDev'))
var maskImage = ndvi.updateMask(ndvi.gt(mean.add(std)));
Map.addLayer(maskImage, {}, 'mask image');
//count number of pixels above the mean+1SD
var count1 = maskImage.reduceRegion({
  reducer: ee.Reducer.count(),
  geometry: table
//count number of pixels below mean+1SD
var unmaskImage = ndvi.updateMask(ndvi.lte(mean.add(std)));
var count2 = unmaskImage.reduceRegion({
  reducer: ee.Reducer.count(),
//count total number of pixels 
var count3 = ndvi.reduceRegion({
  reducer: ee.Reducer.count(),

I have got number of pixels above the mean+1SD:4274; number of pixels below mean+1SD: 52773;total number of pixels: 57047. I have got the number of pixels in ArcGIS for the satellite image in the same day with the same shapefile for the estuary but the total number of pixel is 57060. Why the total number of pixels calculated by GEE and ArcGIS is different?


this problem is no longer a problem for my project. My guess is that the polygon I uploaded into GEE has some projection difference than the Sentinel-2 L1C images in the online dataset.

  • Hi Rose, since you have resolved this could you please accept your answer so that the question is removed from the list of unanswered questions - thanks! – Justin Braaten Jan 20 '20 at 3:27
  • I'm sorry @JustinBraaten how can I accept the answer? – Rose Chai Jan 22 '20 at 2:08
  • Hmmm, I don't know - I've never answered and accepted my own question, though it is apparently possible. Is there an accept button next to the answer when you are signed in - or possibly try up voting it when you are signed in. – Justin Braaten Jan 22 '20 at 17:06
  • Thanks @JustinBraaten I have accepted my own answer by clicking the correct sign:) – Rose Chai Jan 23 '20 at 21:04

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.