0

I am trying to export monthly MODIS Terra Daily NDVI data from Google Earth Engine (GEE). Despite researching various platforms, including this one, I find myself at an impasse. I attempted to implement the solution shared by Ludmila as it closely aligns with my requirements. However, I encountered the following error:

Image (Error) Image.reduce: Unable to reduce an image with 0 bands.

I have novice understanding of GEE. Below is the code I'm using:

// Set years and month
var startYear = 2000;
var endYear = 2023;
var years = ee.List.sequence(startYear, endYear);
var months = ee.List.sequence(1, 12);

// Load the image collection
var dataset = ee.ImageCollection('MODIS/MOD09GA_006_NDVI')
                  .filterDate('2000-01-01', '2023-02-01')
                  .filterBounds(ACC);

// Make monthly summed mosaics
// Loop over the years and months to get summed monthly images
var byMonth = ee.ImageCollection.fromImages(
  years.map(function(y) {
    var yearCollection = dataset.filter(ee.Filter.calendarRange(y, y, 'year'));
    return months.map(function(m) {
      var summedImage = yearCollection.filter(ee.Filter.calendarRange(m, m, 'month'))
        .reduce(ee.Reducer.sum());
      var date = ee.Date.fromYMD(y, m, 1);
      return summedImage.set('system:time_start', date)
        .rename(date.format("MM_dd_YYYY"))
        .divide(10)  // Divide by 10 for scaling, if necessary
        .toFloat();
    });
  }).flatten());

// Filter the empty ones out
var outputMonthly = byMonth.filter(ee.Filter.listContains('system:band_names', 'constant').not())
  .sort('system:time_start').toBands();

// Print the resulting mosaic
print("Output Monthly NDVI Mosaic:", outputMonthly);

// Export the data
Export.image.toDrive({
  image: outputMonthly,
  description: "NDVI_ACC_2000-2023",
  scale: 3000,
  folder: "NDVI_ACC",
  region: ACC,
  maxPixels: 1e13  // Adjust this as needed
});
2
  • 1
    The code shows a different error for a different study area. Can you test the code by removing .divide(10). toFloat() these?
    – Padmanabha
    Commented Aug 28, 2023 at 19:05
  • It worked. Thank you @Padmanabha Commented Aug 28, 2023 at 21:12

0

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.