0

I am wondering why the two approaches to calculate the area of a feature collection return different results and which one is "correct"?

  1. I clip the feature collection on a white image and sum up over the multiplied area
    var whiteImage = ee.Image().unmask().eq(0).rename('test')
    var trueAreaImage = whiteImageClipped.multiply(ee.Image.pixelArea());
    var trueArea = trueAreaImage.reduceRegion({
      reducer: ee.Reducer.sum(),
      geometry: validationRegion,
      scale: 10
    });
  1. The other time I am using a reducer to generate the raster data and sum up over the multiplied area
    var reducedImage = groundTruth.reduceToImage(['test'],'anyNonZero').rename('test')
    var trueAreaImage = reducedImage.multiply(ee.Image.pixelArea());
    var trueArea = trueAreaImage.reduceRegion({
      reducer: ee.Reducer.sum(),
      geometry: validationRegion,
      scale: 10
    });

The result of the two approaches is significantly different.

https://code.earthengine.google.com/8baa2a6c27490ca44d7904f7ab6208be

1 Answer 1

2

The conversion of vector to raster is the likely source of the difference. I'm concluding this based on three other ways of calculating image region area by reduction which produce equal results and none of them use vector to raster conversion.

Code Editor link

// ROI
var roi = ee.Geometry.Polygon(
  [[[-122.18794270981743, 37.238143748045786],
    [-122.18794270981743, 37.02574255804269],
    [-121.82814046372368, 37.02574255804269],
    [-121.82814046372368, 37.238143748045786]]], null, false);

// Get a pixel area image.
var areaImg = ee.Image.pixelArea();

// Calculate area of ROI by image reduction (NO CLIP).
var roiAreaNoClip = areaImg.reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: roi,
  scale: 10
});

// Calculate area of ROI by image reduction (CLIP to ROI).
var roiAreaClip = areaImg.clip(roi).reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: roi,
  scale: 10
});


// Multiply area image by constant 1 image (CLIP to ROI).
var roiAreaMultiplyClip = ee.Image.constant(1).clip(roi).multiply(areaImg)
  .reduceRegion({
    reducer: ee.Reducer.sum(),
    geometry: roi,
    scale: 10
  });

print('Compute area by reduction:', roiAreaNoClip.get('area'));
print('Clip image then compute area by reduction:', roiAreaClip.get('area'));
print('Multiply area image by constant 1 image (CLIP to ROI):', roiAreaMultiplyClip.get('constant'));

Compute area by reduction:
753633057.7863889

Clip image then compute area by reduction:
753633057.7863889

Multiply area image by constant 1 image (CLIP to ROI):
753633057.7863889

It seems like this is an unnecessary step in your example:

var trueAreaImage = reducedImage.multiply(ee.Image.pixelArea());

It could just be:

var area = ee.Image.pixelArea().reduceRegion({
  reducer: ee.Reducer.sum(),
  geometry: <THE COLLECTION USED TO CREATE THE reducedImage VAR>,
  scale: 10
});
1
  • Thank you for your answer Justin, It makes it a little clearer however I am still wondering what area is correct? Because when I compare the result from earth engine to the result I get using other gis software I get a different result. PS: the additional step was necessary because the geometry in the area reducer is not equal to the geometry used when creating reducedImage. They overlap in some parts but are not the same.
    – dude
    Commented Jan 22, 2020 at 10:52

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.