0

I am currently using the Landtrendr algorithm to plot time-series graphs of average NBR values for different levels of burn severity.

I am using the example 'LandTrendr Zonal Time Series Plotter' script provided, however I keep getting the error:

Output of image computation is too large (6 bands for 2413581 pixels = 110.5 MiB > 80.0 MiB).
If this is a reduction, try specifying a larger 'tileScale' parameter

I have added a titleScale parameter of the highest value (16) and have also increased the other scale value and this produces the error:

Computed image is too large.

Is there a way to get around this so I can plot the graphs successfully?

    //#                                                                                                    #\\
    //#                      LANDTRENDR SOURCE AND FITTING ZONAL MEDIAN TIME SERIES                        #\\
    //#                                                                                                    #\\
    //########################################################################################################
    
    // author: Justin Braaten | [email protected]
    // website: https://github.com/eMapR/LT-GEE
    // about: this script will plot a time series of orginal and LandTrendr-fitted data
    //        for the area within a given geometry aggregated by the median function
    
    //########################################################################################################
    //##### INPUTS ##### 
    //########################################################################################################
    
    // get geometry stuff
    var aoi = fire_buffer
    
    // define years and dates to include in landsat image collection
    var startYear = 1985;    // what year do you want to start the time series 
    var endYear   = 2022;    // what year do you want to end the time series
    var startDay  = '01-01'; // what is the beginning of date filter | month-day
    var endDay    = '03-20'; // what is the end of date filter | month-day
    var index = 'NBR';
    var maskThese = ['cloud', 'shadow', 'snow'];
    var summaryScale = 500;
    var runParams = { 
      maxSegments:            6,
      spikeThreshold:         0.9,
      vertexCountOvershoot:   3,
      preventOneYearRecovery: true,
      recoveryThreshold:      0.75,
      pvalThreshold:          0.05,
      bestModelProportion:    0.75,
      minObservationsNeeded:  6
    };
    
    var changeParams = {
      delta:  'gain',
      sort:   'greatest',
      year:   {checked:true, start:2007, end:2013},
      mag:    {checked:true,  value:100,  operator: '>', dsnr:false},
      dur:    {checked:false,  value:4,    operator: '<'},
      preval: {checked:true,  value:0,  operator: '>'},
      mmu:    {checked:true,  value:11},
    };
    
    //########################################################################################################
    //########################################################################################################
    //########################################################################################################
    
    // ----- GET/MAKE FUNCTIONS -----
    var ltgee = require('users/emaprlab/public:Modules/LandTrendr.js');
    
    var getSummary = function(img, geom, scale) {
      return img.reduceRegion({
       reducer: ee.Reducer.median(),
       geometry: geom,
       scale: scale,
       maxPixels: 10e9,
       tileScale: 16
      });
    };
    
    //----- GET FITTED BAND STACK -----
    // run LandTrendr
    
    // add index to changeParams object
    changeParams.index = index;
    
    var lt = ltgee.runLT(startYear, endYear, startDay, endDay, aoi, index, [index], runParams, maskThese);
    
    // get the change map layers
    var changeImg = ltgee.getChangeMap(lt, changeParams);
    
    // clip the image
    var changeImg = changeImg.clip(aoi);
    
    // get the fitted NBR out
    var fitBandStack = ltgee.getFittedData(lt, startYear, endYear, index);
    
    //----- GET RAW BAND STACK -----
    // build annual surface reflectance collection (cloud and shadow masked medoid composite)
    var annualSRcollection = ltgee.buildSRcollection(startYear, endYear, startDay, endDay, aoi, maskThese);
    
    // transform the annual surface reflectance bands to whatever is in the bandList variable
    var indexCollection = ltgee.transformSRcollection(annualSRcollection, [index]);
    
    // transform image collection of NBR (from bandList) to a image band stack
    var rawBandStack = ltgee.collectionToBandStack(indexCollection, startYear, endYear);
    
    //----- GET YEAR BAND STACK -----
    var yearBandStack;
    var tmp;
    for(var yr = startYear; yr <= endYear; yr++){
      tmp = ee.Image(yr);
      tmp = tmp.select([0], [yr.toString()]);
      if(yr == startYear){
        yearBandStack = tmp;
      } else{
        yearBandStack = yearBandStack.addBands(tmp);
      }
    }
    
    var magnitude = changeImg.select('mag').multiply(0.001)
    
    var yod = changeImg.select('yod')
    
    // add year of detection mask to only focus on pixels for the right disturbance
    var yodmask = yod.lte(2009).and(yod.gte(2010));
    
    // select pixels for each severity
    var high_mask = magnitude.lt(1.30).and(magnitude.gte(0.66)).updateMask(yodmask);
    
    var m_high_mask = magnitude.lt(0.66).and(magnitude.gte(0.44)).updateMask(yodmask);
    
    var m_low_mask = magnitude.lt(0.44).and(magnitude.gte(0.27)).updateMask(yodmask);
    
    var low_mask = magnitude.lt(0.27).and(magnitude.gte(0.1)).updateMask(yodmask);
    
    //var mask = mask.updateMask(yodmask);
    
    var yearBandStack = yearBandStack.updateMask(high_mask); 
    var rawBandStack = rawBandStack.updateMask(high_mask); 
    var fitBandStack = fitBandStack.updateMask(high_mask); 
    
    //----- MAKE ARRAYS -----
    var yearSummary = getSummary(yearBandStack, aoi, summaryScale).toArray();
    var rawSummary = getSummary(rawBandStack, aoi, summaryScale).toArray();
    var fitSummary = getSummary(fitBandStack, aoi, summaryScale).toArray();
    var chartArray = ee.Array.cat([rawSummary, fitSummary], 1);
    
    
    //----- PLOT THE TIME SERIES -----
    var chart = ui.Chart.array.values(chartArray, 0, yearSummary)
                  .setSeriesNames(['Original', 'Fitted'])
                  .setOptions({
                    hAxis: {
                      'title': 'Year',
                      'maxValue': startYear,
                      'minValue': endYear,
                      'format': '####'
                    },
                    vAxis: {
                      'title': index,
                      'maxValue': 1000,
                      'minValue': -1000 
                    },
                    pointSize: 0,
                    lineSize: 2,
                });
    
    print(chart);

https://code.earthengine.google.com/12c29d06a2e8807e0c14f68cc378045d

1 Answer 1

0

1. Reduce the Number of Bands: If possible, consider reducing the number of bands in your computed image. Focus on including only the essential bands needed for your analysis or visualization.

2. Spatial and Temporal Aggregation: Instead of processing the entire area at once, try spatially aggregating or reducing the resolution of your data. Temporally aggregate data if you are working with time-series information.

3. ROI Selection: Limit the geographical extent of your computation by selecting a smaller ROI if it aligns with your analysis requirements.

4. Use Image Reducer: Utilize image reducer functions (e.g., reduceRegion, reduceRegionToImage) to summarize or aggregate the information within your region of interest. This can help in generating a smaller output.

var reducer = ee.Reducer.mean(); var scale = 30; var reducedStats = yourImage.reduceRegion({ reducer: reducer, geometry: yourROI, scale: scale });

Hope this helps!

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.