1

I'm facing issue to export a CSV table of a time series from multiple polygons in GEE. Using few polygons it works well, but when I'm adding more polygons, the output is truncated. My CSV has Polygon's names as column and Time as row names. The example code can be found here

var S2 = ee.ImageCollection('MODIS/006/MOD11A2')


.filterDate('2018-09-01', '2018-10-31')

.filterBounds(geometry)

.select ('LST_Day_1km');

var S2cell = S2.map(function(img){ 
  return img. multiply(0.02)
  .subtract(273.15)
  .copyProperties(img,['system:time_start','system:time_end']);
});


var triplets = S2cell.map(function(image) {
  return image.reduceRegions({
    collection: geometry.select(['Name']), 
    reducer: ee.Reducer.mean(), 
    scale: 1000
  }).filter(ee.Filter.neq('mean', null))
    .map(function(f) { 
      return f.set('imageId', image.id()).setGeometry(null);
    });
}).flatten();
print(triplets.first());

var format = function(table, rowId, colId) {
  var rows = table.distinct(rowId);

  var joined = ee.Join.saveAll('matches').apply({
    primary: rows, 
    secondary: table, 
    condition: ee.Filter.equals({
      leftField: rowId, 
      rightField: rowId
    })
  });

  return joined.map(function(row) {
      var values = ee.List(row.get('matches'))

        .map(function(feature) {
          feature = ee.Feature(feature);
          return [feature.get(colId), feature.get('mean')];
        });
      return row.select([rowId]).set(ee.Dictionary(values.flatten()));
    });
};

var table1 = format(triplets, 'imageId', 'Name');

var desc1 = 'table_easimes'; 
Export.table.toDrive({
  collection: table1, 
  description: desc1, 
  fileNamePrefix: desc1,
  fileFormat: 'CSV'
});

print(geometry)

As you can see my Shapefile asset has 15 polygons; but the output only shows 8 polygons. The worst is that I would to compute it over 1600 polygons.

What's wrong ?

  • 1
    Your table is not shared. Possibly, you will loose features where there is no overlap between the imagery and the geometry of those features, which you filter out using .filter(ee.Filter.neq('mean', null)). Moreover, there is no need in filtering MODIS imagery on a geometry, as these images are global (and that's is also the reason filterBounds() does not filter out imagery not covering your study area). – Kuik Sep 19 at 12:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.