I have table of 10 points that I want to extract the mean and standard deviation of NDVI from sentinel within a buffered area for a time period. I am running into a problem where when I reduce it and try to export it to a csv, I get a lot of duplicated rows with 0 values for the calculated statistics.

Example output

Here is the code I am working with:


// buffering around points
var bufferPoly = function(feature) {
  return feature.buffer(2500);   // adjust for buffer size in meters

var zone = sample.map(bufferPoly); 


// Importing sentinel and cropping around feature collection
var sentinel = ee.ImageCollection("COPERNICUS/S2_SR").filterDate('2020-10-01', '2020-10-05')                  
    .map(function(image){return image.clip(zone)});

var count = sentinel.size(); // seeing how many bands there are...shouldn't be too many
print('Bands of sentinel: ', count);

print(sentinel); // we can see what is actually here, it is a collection of 12 images each having two bands

// Calculating NDVI for each image

// NDVI Function
function ndvi(im) {
  return im.normalizedDifference(['B8', 'B4']);

// mapping the ndvi function over all images
var ndvi = sentinel.map(ndvi);

var count = ndvi.size(); // seeing how many bands there are
print('Bands of ndvi: ', count); 

print(ndvi); //We can see that it is a collection of 12 images with one ndvi band

//Now to reduce the image collection in a summary

//now extracting to the polygon

var reducers = ee.Reducer.mean().combine({
  reducer2: ee.Reducer.stdDev(),
  sharedInputs: true

var scale = ndvi.first().projection().nominalScale();

var reduced = ndvi.map(function(image){
  return image.reduceRegions({
    collection:zone , 
    scale: scale

var count = reduced.size(); // There are 12 bands here
print('Bands of reduced: ', count);


var table = reduced.flatten();

var count = table.size(); // There are 120 bands here
print('Bands of table: ', count); 


  collection: table,
  fileFormat: 'csv'

For some reason, this is giving me 12 duplicated rows per the original row in the table. Any idea what is happening here?

link to code: https://code.earthengine.google.com/?scriptPath=users%2Fddlawton%2FAUS_SOILS_TEST%3AExtraction_code

1 Answer 1


When you use .reduceRegions(), you are reducing ndvi over every feature in your feature collection sample. So the first 12 rows contain ndvi (size: 12 images) reduced over the your first feature, the next 12 rows are reduced over your second feature, etc. Since you have 120 rows, sample must have a size of 10.

I am guessing that the ndvi statistics for some rows are blank because there is no overlapping area between the image and feature; when filtering an image collection with .filterBounds(), images will be retained if there is partial overlap with the ee.Geometry you are filtering by.

How do you filter an ee.ImageCollection for images that contain multiple geometries? One idea is to create a list of filters that checks the intersection of the image with multiple coordinates. Assuming that sample is a ee.FeatureCollection with a MultiPoint geometry (based on comments in your code),

var filterboundslist = ee.List(
  // map over list of coordinates 
    return ee.Filter.bounds(ee.Geometry.Point(point))

// filter image collection
var sentinel_filt = sentinel.filter(filterboundslist) 

Depending on the distribution of your sample areas, it is possible that no image intersects with all coordinates at once, in which case sentinel_filt would have a size of zero.

  • so is there a way to filter the image collection to the points of interest without retaining the null data?
    – Douglas
    Dec 11, 2020 at 23:46
  • @Douglas see my editted answer
    – korndog
    Dec 12, 2020 at 2:21

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.