0

Due to the necessity that I have to process the model in specific CRS (EPSG:3006), I try to reproject the ImageCollection after calculating all the vegetation indices I need. I use the code below to reproject that whole imagecollection so that I can continue the further analysis.

var res2L2017c_Veg = s2L2017c_Veg.reduceRegion({
  reducer: ee.Reducer.median(),
  geometry: ROI,
  scale: 10,  // meters
  crs: 'EPSG:3006',  //sweref99 tm
});
print(res2L2017c_Veg)

However, it shows the error:

Dictionary (Error) Image.reduceRegion: Too many pixels in the region. Found 41709676124, but maxPixels allows only 10000000. Ensure that you are not aggregating at a higher resolution than you intended; that is a frequent cause of this error. If not, then you may set the 'maxPixels' argument to a limit suitable for your computation; set 'bestEffort' to true to aggregate at whatever scale results in 'maxPixels' total pixels; or both.

Does it mean that it exceeds the computation affordability of GEE? How should I correct this error?

This is the link to my code: https://code.earthengine.google.com/6a40e656de80a79aa4308c97f313b756

This is the geometry "ROI": https://code.earthengine.google.com/?asset=projects/ee-sweden2023study/assets/ROI

1 Answer 1

0

As the error message informs, the issue is with the maxPixels value. You can simply add it as an argument increasing the maxPixels allowed:

var res2L2017c_Veg = s2L2017c_Veg.reduceRegion({
  reducer: ee.Reducer.median(),
  geometry: largearea,
  scale: 10,  // meters
  crs: 'EPSG:3006',  //sweref99 tm
  maxPixels: 41709676125
});

It will take time and it could run out of memory since the area is huge

7
  • 1
    Adding to this: If it still runs out of memory with the maxPixels set to max then you'll either have to reduce the size of your area or increase the scale
    – M. Nicolas
    Apr 13 at 19:29
  • 1
    Exactly, thanks for the addition. Scale equal to 10 is too detailed for this area
    – aldo_tapia
    Apr 13 at 19:34
  • Thank you! I have tried but it showed "Computation timed out." maybe it's due to the large area and high resolution I assigned. According to the suggestions from GEE (developers.google.com/earth-engine/guides/debugging), I should reproject while exporting, which means I cannot conduct further analysis with this CRS. Am I correct?
    – Lin Annie
    Apr 13 at 19:59
  • Thank you! I just saw your comments. I'm afraid the study area is fixed and the scale is also required to be as detailed as possible. If I skip this part and convert my CRS of other data (training dataset) to the GEE default one, which means I don't do any reprojection to this imagecollection. Would it be better?
    – Lin Annie
    Apr 13 at 20:06
  • 1
    Actually using a scale of 1000, the computation is super fast. If you can't reduce the scale, split the area into smaller polygons and then you can aggregate statistics weighted by area
    – aldo_tapia
    Apr 13 at 22:13

Your Answer

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

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