2

I am trying to export a resampled image from Google Earth Engine, and keep getting errors such as -

Error: Reprojection output too large (23734x8520 pixels).

As shown in the following screenshot -

enter image description here

The error can be reproduced using the sample script from https://developers.google.com/earth-engine/resample#reduce-resolution as follows -

// Load a MODIS EVI image.
var modis = ee.Image(ee.ImageCollection('MODIS/006/MOD13A1').first())
    .select('EVI');

// Display the EVI image near La Honda, California.
Map.setCenter(-122.3616, 37.5331, 12);
Map.addLayer(modis, {min: 2000, max: 5000}, 'MODIS EVI');

// Get information about the MODIS projection.
var modisProjection = modis.projection();
print('MODIS projection:', modisProjection);

// Load and display forest cover data at 30 meters resolution.
var forest = ee.Image('UMD/hansen/global_forest_change_2015')
    .select('treecover2000');
Map.addLayer(forest, {max: 80}, 'forest cover 30 m');

// Get the forest cover data at MODIS scale and projection.
var forestMean = forest
    // Force the next reprojection to aggregate instead of resampling.
    .reduceResolution({
      reducer: ee.Reducer.mean(),
      maxPixels: 1024
    })
    // Request the data at the scale and projection of the MODIS image.
    .reproject({
      crs: modisProjection
    });

// Display the aggregated, reprojected forest cover data.
Map.addLayer(forestMean, {max: 80}, 'forest cover at MODIS scale');

The script works fine and the resampled image forestMean is shown on the map.

However, trying to export the image with the following expressions leads to the above-mentioned error -

// Continental USA polygon
var pol = ee.Geometry.Polygon([[[-126.21093749999999,23.241346102386135],[-67.8515625,23.241346102386135],[-67.8515625,48.922499263758255],[-126.21093749999999,48.922499263758255],[-126.21093749999999,23.241346102386135]]]);

// Export
Export.image.toDrive({
  image: forestMean,
  description: "forest_example",
  scale: 926.6254330555, 
  region: pol
});

It is important to note that the same error appears even when using a very small export region.

Update:

As Philipp Gärtner discovered, this seems to be an issue of export area size. Using a very small area indeed works.

For example, the following very small export area works - enter image description here

While this one doesn't work - enter image description here

  • 1
    I tested your code with a very small export region var geometry = ee.Geometry.Polygon( [[[-120.63911377553933, 38.38790575083015], [-120.63911377553933, 37.443193213651234], [-118.98017822866433, 37.443193213651234], [-118.98017822866433, 38.38790575083015]]], null, false); and had no problem exporting the image. Export.image.toDrive({ image: forestMean, description: "forest_example", scale: 926.6254330555, region: geometry, maxPixels: 1e13}); – Philipp Gärtner Apr 11 at 11:53
  • Thanks! You're right, I've updated the question to give an example of this. – Michael Dorman Apr 11 at 12:23
1

It seems that the problem you are running into is that when Earth Engine is trying to reduce the resolution there are too many pixels going into the aggregation calculation at the scale you are requesting at. A way to circumvent the problem is to set the bestEffort argument to true and lower the maxPixel values in reduceResolution(). Here is a working example:

// Load a MODIS EVI image.
var modis = ee.Image(ee.ImageCollection('MODIS/006/MOD13A1').first())
    .select('EVI');

// Display the EVI image near La Honda, California.
// Map.setCenter(-122.3616, 37.5331, 12);
Map.addLayer(modis, {min: 2000, max: 5000}, 'MODIS EVI');

// Get information about the MODIS projection.
var modisProjection = modis.projection();
print('MODIS projection:', modisProjection);

// Load and display forest cover data at 30 meters resolution.
var forest = ee.Image('UMD/hansen/global_forest_change_2015')
    .select('treecover2000');
Map.addLayer(forest, {max: 80}, 'forest cover 30 m');

// Get the forest cover data at MODIS scale and projection.
var forestMean = forest
    // Force the next reprojection to aggregate instead of resampling.
    .reduceResolution({
      reducer: ee.Reducer.mean(),
      maxPixels: 64,
      bestEffort:true
    })
    // Request the data at the scale and projection of the MODIS image.
    .reproject({
      crs: modisProjection
    });

// Display the aggregated, reprojected forest cover data.
Map.addLayer(forestMean, {max: 80}, 'forest cover at MODIS scale');

// Continental USA polygon
var pol = ee.Geometry.Rectangle([-125,25,-67,49],'EPSG:4326',false);

Map.addLayer(pol,{color:'red'},'Export Region')

// Export
Export.image.toDrive({
  image: forestMean,
  description: "forest_example",
  scale: 926.6254330555, 
  region: pol,
  maxPixels:1e13
});

I tried the export over the CONUS and it took 8 minutes (resulting image below in QGIS). Be careful of the resulting values though...since you are lowing the number of pixels going into the resolution reduction, the MODIS scale values may not be absolutely accurate.

I hope this helps!

result image

  • This clarifies the situation, thanks. However, I need the averages to be based on the entire sample of matching pixels, so this solution is unsuitable for what I need. – Michael Dorman Apr 14 at 14:58
  • 1
    That is understandable. Another way to do it is to make an export grid with tiles that Earth Engine can export reliable results, export multiple images, and merge them all locally when you are done. – Kel Markert Apr 14 at 15:01
  • Indeed, in the past an area as large as the CONUS could be exported in tiles. Now that it no longer works, I'm not sure it is worth the effort to split the processing to tiles in the code, then execute all of the Google Drive exports one by one, etc. Perhaps will look for an alternative to GEE. – Michael Dorman Apr 14 at 15:16

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.