I'm following this example to create zonal statistics for EVI images in Google Earth Engine. In my code (GEE code here) I have a FeatureCollection of points, that creates a 3km buffer for each point, and with it, finally, calculate the mean value for each polygon.

It looks like a very straightforward code but I'm having this headache to get it returning the mean value

When I print(reducer_mean) it should return the mean values for each region. Instead it's retuning null:

properties: Object (5 properties)
0_0: null
1_1: null
2_2: null

I'm wondering if someone could help me to figure out where the inconsistency of the code are. Because I can manage to find it.

Snapshot of my code:

function create_Landsat_img( year, name ){
  // settings for landsat 8
  var imgCol = "LANDSAT/LC08/C01/T1_TOA";
  var band_nir= "B5";
  var band_red= "B4";
  var band_blue= "B2";
  var img = ee.ImageCollection(imgCol)
  .filterDate(year+"-01-01", year+"-12-31")
  .filterMetadata('CLOUD_COVER', 'less_than', 95)
  // calculate the evi
  var evi = img.expression("2.5 * ((nir - red) / (nir + 6 * red - 7.5 * blue + 1))",
      nir : img.select(band_nir),
      red : img.select(band_red),
      blue: img.select(band_blue)
  // add the evi to the map
  Map.addLayer(evi,{min:0,max:0.85,palette:"blue,red,yellow,green,darkgreen"}, name);
  return evi;

//--- START SCRIPT ---
// Create a function for Buffering a feature, using the buffer_size
// property of the feature.
var BufferFeature = function(f) {
  f = ee.Feature(f);
  var buffer_size = f.get('buffer_size');
  return f.buffer(buffer_size);   

var BufferFeaturesByDistance = function (fc, buffer_size) {
  // Set a buffer_size property on a feature. Note that this function needs
  // to be defined within the BufferFeaturesByDistance function, so it can
  // make use of the buffer_size parameter.
  var SetBufferSize = function(f) {
    return f.set({'buffer_size': buffer_size});

  return POI.map(SetBufferSize).map(BufferFeature);

var buffered = BufferFeaturesByDistance(POI, 3000); // 3km buffer
// Create EVI layers
var i;
var num_years_range = 3; 
var images_list = [];
for(i = num_years_range; i >= 1; i--){
  var year = 2022;
  var yearImg = year-i;
  year = yearImg.toString();
  var nameLayer= "EVI_"+year;
  var EVI_Layer = create_Landsat_img(year, nameLayer);
  images_list.push( EVI_Layer );

var imgCol = ee.ImageCollection.fromImages(images_list);

var rename_band = function(img){
  return img.select([0], [img.id()]);

// stack all the images into a single image.
var stacked_image = imgCol.map(rename_band).toBands(); //iterate(combine, stacked_image);

// determine scale to perform reduceRegions.
var scale = imgCol.first().projection().nominalScale();

// calculate the timeseries for each feature.
var reducer_mean = ee.Image(stacked_image).reduceRegions({collection: buffered, reducer: ee.Reducer.mean(), scale: scale});

  collection: reducer_mean,
  description: 'tableOutput',
  fileFormat: 'KML',
  folder: 'GoogleEarthEngine'

// Add to layer
Map.addLayer(buffered, {color:'green'}, 'buffered');
// Zooming to layer
  • I think the scale you are setting is much too large. I tried setting the scale to 500 and it worked great.
    – M. Nicolas
    Jan 11, 2022 at 22:58

1 Answer 1


Try reducing the scale; you're currently using the reducer at 1 degree (~110km), which is much larger than the size of your geometries:


Setting the scale to 30 meters (the scale of bands B2, B4 and B5), fixes the issue:

var reducer_mean = ee.Image(stacked_image).reduceRegions({collection: buffered, reducer: ee.Reducer.mean(), scale: 30});

    properties: Object (5 properties)
    0_0: 0.4079238581747526
    1_1: 0.39326260869897006
    2_2: 0.35812035383587515
    buffer_size: 3000
    class: 0

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.