I am trying to get a time series of MODIS NDVI for a point, with the script below and it works quite well, except when I try to include the year 2017 where I get the following error message:

ID: B4E7LMH7MMFMCKFWYPOAGT2E Phase: Failed Runtime: 28m (started 2022-02-15 15:37:39 +0100) Attempted 1 time Error: Error in map(ID=159): Image.reduceRegions: Need 1 bands for Reducer.mean, image has 0. (Error code: 3)

Apparently, my mapping function must be coming up with an empty image. Someone had suggested to me to use the ee.ImageCollection​ method getRegion(). However, I don't know how it works and how to solve this problem.

Here is the script:

var point = ee.Geometry.Point([0,0])
var pts = ee.FeatureCollection(point)    

function bufferPoints(radius, bounds) {
  return function(pt) {
    pt = ee.Feature(pt);
    return bounds ? pt.buffer(radius).bounds() : pt.buffer(radius);
var ptsTopo = pts.map(bufferPoints(500, false));

var modis = ee.ImageCollection('MODIS/MOD09GA_NDVI')
            .map(function(img){var d = ee.Date(ee.Number(img.get('system:time_start')));
              var m = ee.Number(d.get('month'));
              var y = ee.Number(d.get('year'));
              return img.set({'month':m, 'year':y});
var months = ee.List.sequence(1, 12);
var years = ee.List([2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017]);
var byYearMonth = ee.ImageCollection.fromImages(
        return months.map(function(m){
          return modis.filterMetadata('year', 'equals', y)
                      .filterMetadata('month', 'equals', m)
                      .set('year', y)
                      .set('month', m)
                      .set('date', ee.Date.fromYMD(y,m,1));
var proj = ee.Image(modis.first()).projection()

var NDVI_pts = byYearMonth.map(function(img){
  var features = ptsTopo.map(function(f) {return f.set('date', img.get('date'), 'month', img.get('month'), 'year', img.get('year'))})
  return img.reduceRegions(features, ee.Reducer.mean(), 500, proj);

Export.table(NDVI_pts, 'NDVI_pts', {fileFormat: 'CSV'});

1 Answer 1


This probably comes from an image that doesn't contain any unmasked pixels for the region you're reducing. You could solve it by using reduceRegion() instead of reduceRegions(). You will then get features without your NDVI property, that you optionally could filter out.

var NDVI_pts = byYearMonth
  .map(function(img) {
    return ptsTopo
      .map(function(f) {
        return ee.Feature(
            reducer: ee.Reducer.mean(), 
            geometry: f.geometry(), 
            scale: 500
        ).set('date', img.get('date'), 'month', img.get('month'), 'year', img.get('year'))
  // .filterMetadata('NDVI', 'not_equals', null)


  • Thanks, your solution works perfectly for exporting the results, but it does not solve the problem of empty values in the dates from April 2017. Does this mean that there is no MODIS NDVI data on these dates?
    – Bouram
    Feb 19, 2022 at 11:22
  • You only have imagery Jan, Feb, Mar in 2017: code.earthengine.google.com/d9f4c160f6d9d4e9b9cc33edd3d63c5f Feb 21, 2022 at 9:57
  • So yes, there are months where you don't have any data at all. This triggered an error in your original script. Feb 21, 2022 at 10:00

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.