3

I have been working with Google Earth Engine (GEE) and I encountered an unexpected discrepancy in the output when calculating the area of a geometry using different methods. Specifically, I noticed that the featureCollection.geometry().area() function and the ee.Image.pixelArea().reduce(geometry) operation yield different results.

To provide some context, I have a FeatureCollection in GEE that contains several features with geometries representing different regions of interest. My goal is to compute the area of these geometries accurately. Initially, I used the featureCollection.geometry().area() method, which is commonly used to calculate the area of a geometry directly from a FeatureCollection object.

However, I noticed that the results obtained from this method differed from the ones obtained by utilizing the ee.Image.pixelArea().reduce(geometry) operation. This operation involves creating an ee.Image object and then applying the reduce() function on the geometry of interest.

I would like to understand why these two methods produce inconsistent results. Is there a fundamental difference in how these functions calculate the area? Could it be related to the spatial resolution of the imagery used in ee.Image.pixelArea()? How can I obtain accurate area calculations?

Here is a simplified code snippet demonstrating the issue:

var fc = ee.FeatureCollection("your/feature/collection");

// Method 1: Calculating area using featureCollection.geometry().area()
var areaMethod1 = fc.geometry().area();

// Method 2: Calculating area using ee.Image.pixelArea().reduce(geometry)
var areaMethod2 = ee.Image.pixelArea().reduceRegion({
  geometry: geomFeature.geometry(),
  reducer: ee.Reducer.sum(),
  scale: 30
})

print('Area (Method 1):', areaMethod1);
print('Area (Method 2):', areaMethod2);

1 Answer 1

2

I think that the fundamental difference is that when a polygon is rasterized then the original geometry gets lost.

The ee.Image.pixelArea() gives a sum of the area of the pixels but they can never present the vector geometry exactly. The difference gets smaller with smaller pixels size. See this image with a triangle and a rasterized version of it.

enter image description here

3
  • do you mean the green triangle is what we get from fc.geometry().area() and the grey one from the reduceRegion() approach? Jul 1, 2023 at 18:17
  • Yes, pixelArea is summing the areas of the grey squeres=pixels.
    – user30184
    Jul 1, 2023 at 18:38
  • I'm facing the same issue and I'm at a loss as to what should be a accepted difference. Here I calculated the area of a "square" using geometry().area() and reduceRegion() and I'm getting 0.4% difference in the result. Is that expected / accepted? code.earthengine.google.com/0c88507541891fc8858c52b0a0f33101
    – Daniel
    Nov 7, 2023 at 11:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.