I'm seeing a very strange result using .pixelArea() on two different layers that should yield identical results. Code within GEE is here, also reproduced below:
var states = ee.FeatureCollection("ft:1KU0yvyS5glqa5NmHHl9j9_v-12s_b5YA90qUn9Y");
var test1 = ee.Image("users/test1");
var test2 = ee.Image("users/test2");
test1 = test1.updateMask(test1.gt(0));
test1 = test1.updateMask(test1.lt(999));
var maskedArea = ee.Image.pixelArea().mask(test1);
var maskedArea2 = ee.Image.pixelArea().mask(test2);
print(maskedArea.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: states.filterMetadata('name','equals', 'California'), //geographic area you want summary stats for -- comment the whole line out if you want CONUS
maxPixels: 10e13,
scale: 30
}).get("area"));
print(maskedArea2.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: states.filterMetadata('name','equals', 'California'), //geographic area you want summary stats for -- comment the whole line out if you want CONUS
maxPixels: 10e13,
scale: 30
}).get("area"));
In test1, I uploaded an asset that included cells I didn't want to consider -- hence my use of .updateMask() to remove those cells (any cells with values >0 and <999)
In test2, I uploaded the same asset, except the removal of cells with values >0 and <999 had been done in ArcGIS beforehand (using the "Con" tool). This dataset was in USA Contiguous Albers Equal Area Conic (ESRI: 102003) projection, with a cell size of 30m.
I then calculate the area and get 127,179 for test1 and 145,685 for test2, as you'll see from running the code. What I would like to see is two identical numbers. I am not sure which one of these numbers is "correct", but strongly suspect it is the latter, since it is close to the ArcGIS zonal statistics result and previous findings by others, which I trust.
You can also see from the code link to GEE above that test1 & test2, if added to the map, are completely identical, so the removals of unwanted cells in both cases appear to have worked identically.
How is it possible that these area numbers are so different? (I looked at some other places around the country using similar data snippets & the difference is sometimes not so big, often as much as a factor of 2, on average about ~1.6x bigger -- always bigger in test2, the case where I removed unwanted cells within ArcGIS before uploading the asset).
Hard to imagine simplifying the problem any further, so I'm pretty stumped. I think it has something to do with test1 cells having floating-point values and test2 cells having only 1s and 0s. But, all non-zero cells in both tests are the same, so when used as a mask on ee.Image.pixelArea(), I would think it shouldn't make a difference -- the same parts of the .pixelArea() image should get pulled out.