0

I have generated a Feature Collection for a geometry with 6 polygons. Formatted the table and then exported the first three feature collections having over 1000 properties. However the last batch file times out giving a computation error.

Link to the code: https://code.earthengine.google.com/6c29596851cc826a98b73fdfc0dde165

Asset Link: https://code.earthengine.google.com/?asset=projects/ypm-rs-ml/assets/farms_6

.
.
// Part of the code used to generate the last feature collection to be exported as table later
// Apply smoothing

var oeel = require('users/OEEL/lib:loadAll');
var order = 3;

var sgFilteredCol = oeel.ImageCollection.SavatskyGolayFilter(
  regularCol, 
  maxDiffFilter,
  distanceFunction,
  order)
// This fails as computation times out
print(sgFilteredCol.size(), sgFilteredCol.first())

// Table 4:
var viBandsSmoothed = sgFilteredCol.select(bandsListForSmoothing)
//print('viBandsSmoothed', viBandsSmoothed)

var vegIndicesSmoothed = viBandsSmoothed.map(function(image) {
  var withStats = image.reduceRegions({
  collection: geometry,
  reducer: ee.Reducer.mean(),
  scale: 10
  }).map(function(feature) {
    return feature.set('imageId', ee.Date(image.get('system:time_start')).format('YYYY-MM-dd'))
  })
  return withStats
}).flatten()

var format = function(table, rowId, colId) {
  var rows = table.distinct(rowId); 
  var joined = ee.Join.saveAll('matches').apply({
    primary: rows, 
    secondary: table, 
    condition: ee.Filter.equals({
      leftField: rowId, 
      rightField: rowId
    })
  });
  
  return joined.map(function(row) {
      var values = ee.List(row.get('matches'))
        .map(function(feature) {
          feature = ee.Feature(feature);
          // ['ndvi','gndvi','evi2','savi','ndre','ndwi','rvi','dvi','mcari']
          var ndvi = ee.List([feature.get('d_0_ndvi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var gndvi = ee.List([feature.get('d_0_gndvi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var evi2 = ee.List([feature.get('d_0_evi2'), -9999]).reduce(ee.Reducer.firstNonNull());
          var savi = ee.List([feature.get('d_0_savi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var ndre = ee.List([feature.get('d_0_ndre'), -9999]).reduce(ee.Reducer.firstNonNull());
          var ndwi = ee.List([feature.get('d_0_ndwi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var rvi = ee.List([feature.get('d_0_rvi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var dvi = ee.List([feature.get('d_0_dvi'), -9999]).reduce(ee.Reducer.firstNonNull());
          var mcari = ee.List([feature.get('d_0_mcari'), -9999]).reduce(ee.Reducer.firstNonNull());
          
          return [[ee.String(feature.get(colId)).cat('_ndvi'), ee.Number(ndvi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_gndvi'), ee.Number(gndvi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_evi2'), ee.Number(evi2).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_savi'), ee.Number(savi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_ndre'), ee.Number(ndre).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_ndwi'), ee.Number(ndwi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_rvi'), ee.Number(rvi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_dvi'), ee.Number(dvi).format('%.3f')],
                  [ee.String(feature.get(colId)).cat('_mcari'), ee.Number(mcari).format('%.3f')],
                 ];
        });
        
      return row.select([rowId]).set(ee.Dictionary(values.flatten()));
    });
};

var timeSeriesSmoothed = format(vegIndicesSmoothed, 'Farm_Id', 'imageId');

Export.table.toDrive({
  collection: timeSeriesSmoothed,
  description: 'smoothed',
  folder: 'earthengine',
  fileNamePrefix: 'smoothed',
  fileFormat: 'CSV'})

Tried a couple of Batch export options and also to export the table as an Asset if that helps. It was not helpful. Is there any way to perform the operation tile-wise and then export in batches or export the final feature collection itself in batches?

1 Answer 1

0

"Error: User memory limit exceeded. (Error code: 3)"

I think it's one of the most requested errors about GEE. You are most certainly trying to compute too much data on a too big surface.

As a mitigation solution try to reduce the scale of your reducer (currently 10m)

Also if you want to get a better answer, try to create a minimal reproducible example (https://stackoverflow.com/help/minimal-reproducible-example), it will show that you did try to find a solution on your own and exclude the code that does work (I guess that out of these 400 lines, some is working).

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.