I'm trying to estimate max min NDVI values from the NDVI datasets that came from Landsat images 4-5-7-8. For the max NDVI I used the "qualityMosaic" and it seems that it works okay, but for the min NDVI value I get an error message

MIN NDVI: Layer error: Computation timed out

I've attached the GEE code.

// Function to cloud mask Landsat 8.
var maskL8SR = function(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = ee.Number(2).pow(3).int();
  var cloudsBitMask = ee.Number(2).pow(5).int();
  // Get the QA band.
  var qa = image.select('pixel_qa');
  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0).and(
  return image
      // Scale the data to reflectance and temperature.
      .select(['B4', 'B5'], ['RED', 'NIR']).multiply(0.0001)
      .addBands(image.select(['B11'], ['Thermal']).multiply(0.1))

// Function to cloud mask Landsats 5-7
var maskL57SR = function(image) {
  var qa = image.select('pixel_qa');
  // Second bit must be zero, meaning none to low cloud confidence.
  var mask1 = qa.bitwiseAnd(ee.Number(2).pow(7).int()).eq(0).and(
      qa.bitwiseAnd(ee.Number(2).pow(3).int()).lte(0)); // cloud shadow
  // This gets rid of irritating fixed-pattern noise at the edge of the images.
  var mask2 = image.select('B.*').gt(0).reduce('min');
  return image
      .select(['B3', 'B4'], ['RED', 'NIR']).multiply(0.0001)
      .addBands(image.select(['B6'], ['Thermal']).multiply(0.1))

// find all data and filter them by date
var lst5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_SR')
    .filterDate('1984-10-01', '2011-10-01')
    .map(function(image){return image.clip(roi)});

var lst7 = ee.ImageCollection('LANDSAT/LE07/C01/T1_SR')
  .filterDate('2011-10-01', '2013-04-07')
  .map(function(image){return image.clip(roi)});

 var lst8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
     .filterDate('2013-04-07', '2018-05-01')
    .map(function(image){return image.clip(roi)});

// Combine all landsat data, 1985 through 2015
var L4578 = ee.ImageCollection(lst5.merge(lst8));
L4578 = L4578.merge(lst7);

// create function to add NDVI using NIR (B5) and the red band (B4)
var getNDVI = function(img1){
  return img1.addBands(img1.normalizedDifference(['NIR','RED']).rename('NDVI'));

// map over image collection
var l8ndvi = L4578.map(getNDVI).select('NDVI');

// for each pixel, select the "best" set of bands from available images
// based on the maximum NDVI/greenness
var composite = l8ndvi.qualityMosaic('NDVI').clip(roi);

print (composite);

//set visualization parameters for Maximum NDVI            

var ndviParams = {min: 0, max: 1, palette: ['red', 'yellow', 'green']};
Map.addLayer(composite.select('NDVI'), ndviParams, 'Maximun NDVI');

//For each pixel, select the "worst" set of bands from available images
//based on minimum NDVI
// reduce the image collection to one image by taking MIN of the rasters
var reducemin_NDVI = l8ndvi.reduce(ee.Reducer.min());

// get min NDVI values by ROI polygon

var NDVImin = reducemin_NDVI.reduceRegions({
  collection: roi,
  reducer: ee.Reducer.min(),
  scale: 30 // the resolution of the dataset


//set visualization parameters for MIN NDVI            

var ndviParams = {min: 0, max: 1, palette: ['red', 'yellow', 'green']};
Map.addLayer(NDVImin, ndviParams, 'MIN NDVI');


Your Answer

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

Browse other questions tagged or ask your own question.