Exporting images from image collection in Google Earth Engine - user memory limit exceeded

1.4k Views Asked by At

I'm fairly new to GEE, and I'm trying to process some imagery, then download the results. I need to mask about 30 years of Landsat data to isolate different land cover types, remove clouds, and calculate vegetation indices. Then, I need to export these data to do further analyses in R. I've managed to do all of the masking and calculating vegetation indices, but when I go to export the data, it gives me the user memory limit exceeded error. I tried to only download 1 year of data at a time but got the same error. I'm not sure how to accomplish what I'm doing, which is to do the heavy processing of the data in GEE then export it to do the additional analyses elsewhere. Any recommendations? Code below.

Edit: Added the ROI information as recommended.

var l8sr = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterDate('2013-07-01','2018-06-30');
  
//Function to mask forest
var maskForest = function(img){
  var mask = forest.eq(1);
  return img.updateMask(mask);
};

// Function to mask flooded area
var maskFld = function(img){
  var mask = fldpln.eq(1);
  return img.updateMask(mask);
};

// Cloud masking function
var mask = require('users/fitoprincipe/geetools:cloud_masks');

var mask_fun = mask.landsatSR();

// Create EVI mapping functions
var EVI8 = function(img){
  var evi = img.expression(
  '2.5*((NIR/10000-RED/10000)/(NIR/10000 + 6 * RED/10000 - 7.5 * BLUE/10000 + 1))', {
    'NIR': img.select('B5'),
    'RED': img.select('B4'),
    'BLUE': img.select('B2')
  }).rename('EVI');
return(img.addBands(evi));
};

// Map the forest/savanna/cloud masks and indices to the image collections and select the VI bands
var l8srFldFor = l8sr.map(maskForest).map(maskFld).map(mask_fun).map(EVI8)

// Download images from collection to Drive
var batch = require('users/fitoprincipe/geetools:batch');

var roi = ee.Geometry.Rectangle([[-48.425,-9.577],[-48.036,-8.390]]);

batch.Download.ImageCollection.toDrive(l8srFldFor, 'LandsatTiles', 
                {scale: 30, 
                region: roi,
                 type: 'float'});```
2

There are 2 best solutions below

1
On BEST ANSWER

I think the problem is that you are not applying any spatial filter to the landsat 8 collection. Therefore, the resulting collection is including every landsat 8 image acquired from '2013-07-01' to '2018-06-30'. So probably that was causing the user memory limit exceeded error. To apply a spatial filter based on your roi you should use filterBounds.

var roi = ee.Geometry.Rectangle([[-48.425,-9.577],[-48.036,-8.390]]);
var l8sr = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
  .filterDate('2018-05-01','2018-06-30')
  .filterBounds(roi);
2
On

Are you trying to download from all over the world?