I'm using the GlobalSurfaceWater-Dataset in GEE for creating a mask layer. The mask I do need should only contain water areas bigger than a certain threshold, so I need to get an information on the area of each of the patches. I did try the .reduceConnectedComponents() function using a sum reducer:
var double= extentGSW.addBands(extentGSW);
var patchreduce= double.reduceConnectedComponents({
labelBand: "max_extent",
reducer: ee.Reducer.sum(), //sum up nr of pixels per patch
maxSize: 2000,
});
I would think this should lead to each pixel in one patch getting assigned the value of the total number of pixel in that patch, which would represent the area. However in the output layer pixels in a patch that visibly consist of e.g. two pixels have values of 300. Is there some error in the code? Or rather some problems with scale/projection maybe? Requesting the scale (pixel size) of the output layer returns 30m, which actually is the correct resolution for GSW.
Did also try the .connectedPixelCount() function, but it lead to the same problem. Some hints? If my question isn't very understandable, I'm sorry but ready to answer any querys..