0

I am trying to sample the Global Forest Change dataset using randomly drawn points and the reduceRegion function. The way I construct this is:

var sampledPoints = gfc2014_c.reduceRegions({
  collection:points,
  reducer: ee.Reducer.mean()
});

Where gfc2014_c is the GFC datset cropped to sub-Saharan Africa and points are my randomly drawn points. The entire code is here.

I was aiming for a large sample of 1 million pixels. When I try to export in chunks (even chunks as small as 5,000) I get the following error:

Error: image.reduceRegions: Computed value is too large.

What am I doing wrong? I know the GFC dataset is really large, but it must be possible, right?

  • Interesting problem. I'll tinker with it over the weekend. In the meantime, try: 1) preping your point sample with all the joins etc and export it as an asset, then import it to do the region reduction; 2) don't clip the image data being reduced; 3) try mapping reduceRegion over the point sample instead of using reduceRegions (developers.google.com/earth-engine/…) – Justin Braaten Dec 28 '19 at 0:44
  • Thank you Justin. I just tried your third suggestion, currently attempting an export of 100,000 observations. Fingers crossed! – C. Ashley Dec 28 '19 at 17:51
  • What was the outcome - keep me posted. – Justin Braaten Dec 29 '19 at 20:30
  • Mapping - reduce region sped up the process a lot. Thanks! – C. Ashley Dec 31 '19 at 1:16
  • I'm glad that mapping reduceRegion() resulted in better performance! – Justin Braaten Dec 31 '19 at 23:35
1

Based on Justin's comment above and the part of the debugging guide he directed me to, I tried the following:

var sampledPoints = points.map(function(feature) {
  return feature.set(gfc2014.reduceRegion({
    reducer: 'mean',
    geometry: feature.geometry(),
  }));
});

This seems to have worked: I can now export a chunk of 100,000 observations in 5 hours. Thank you Justin!

| improve this answer | |

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.