在 Google Earth Engine 中导出大型时间序列

Export large time series in Google Earth Engine

如何导出特定区域的大型时间序列?我们的想法是获得 table 的日期和该区域的平均波段值。在这种情况下,它将是一个区域的平均 NDVI。

var collectionModNDVI = ee.ImageCollection('MODIS/006/MOD13Q1')
        .filterDate('2002-01-01', '2017-11-17');

在单点时间序列的情况下,它将是

var geom = ee.Geometry.Point(-1,40).buffer(250);

print(ui.Chart.image.series(collectionModNDVI, geom, ee.Reducer.mean(), 30));

这运行良好,您会得到一个图表,您可以在其中下载 csv 格式的时间序列。但是当它是一个大区域时,我会遇到内存和计算时间的问题。

var table2 = ee.Geometry.Rectangle(-1,40,0,41); 

chart = ui.Chart.image.seriesByRegion(collectionModNDVI,table2,
       ee.Reducer.mean(), 'NDVI',30, 'system:time_start', 'label');

print(chart);

使用此代码时出现以下错误 "User memory limit exceeded"。

我也试过这个:

Export.table.toDrive({
  collection: chart,
  description:'vectorsToDriveExample',
  fileFormat: 'csv'
});

但我得到了和 "d.yc is not a function" 相同的错误。

您需要提供有关 table 格式的更多信息。下面是导出单个波段的两种方法示例:

var roi = /* color: #d63000 */ee.Geometry.Polygon(
        [[[-122.27577209472656, 37.891247253777074],
          [-122.27577209472656, 37.86875557241152],
          [-122.24040985107422, 37.86875557241152],
          [-122.24040985107422, 37.891247253777074]]], null, false);

// Load imagery.
var l8 = ee.ImageCollection('LANDSAT/LC8_SR')
    .filterBounds(roi)
    .filterDate('2016-01-01', '2016-12-31')
    .map(function(image) {
      var qa = image.select('cfmask');
      var mask = qa.neq(2).and(qa.neq(4));
      return image.updateMask(mask).divide(10000);
    });
print('Size of Landsat collection', l8.size()); // 21

// Load an Earth Engine table.
var blocks = ee.FeatureCollection('TIGER/2010/Blocks');
var subset = blocks.filterBounds(roi);
print('Size of Census blocks subset', subset.size()); // 409

Map.centerObject(roi, 13);
Map.addLayer(blocks, {color: 'gray'}, 'blocks');
Map.addLayer(subset, {}, 'subset');

// Collect block, image, value triplets.
var triplets = l8.map(function(image) {
  return image.select('B1').reduceRegions({
    collection: subset.select(['blockid10']), 
    reducer: ee.Reducer.mean(), 
    scale: 30
  }).filter(ee.Filter.neq('mean', null))
    .map(function(f) { 
      return f.set('imageId', image.id());
    });
}).flatten();
print(triplets.first());

// Format a table of triplets into a 2D table of rowId x colId.
var format = function(table, rowId, colId) {
  // Get a FeatureCollection with unique row IDs.
  var rows = table.distinct(rowId);
  // Join the table to the unique IDs to get a collection in which
  // each feature stores a list of all features having a common row ID. 
  var joined = ee.Join.saveAll('matches').apply({
    primary: rows, 
    secondary: table, 
    condition: ee.Filter.equals({
      leftField: rowId, 
      rightField: rowId
    })
  });

  return joined.map(function(row) {
      // Get the list of all features with a unique row ID.
      var values = ee.List(row.get('matches'))
        // Map a function over the list of rows to return a list of
        // column ID and value.
        .map(function(feature) {
          feature = ee.Feature(feature);
          return [feature.get(colId), feature.get('mean')];
        });
      // Return the row with its ID property and properties for
      // all matching columns IDs storing the output of the reducer.
      // The Dictionary constructor is using a list of key, value pairs.
      return row.select([rowId]).set(ee.Dictionary(values.flatten()));
    });
};

var link = '78503bfa1fb76b3a9fa06b515d1e2488';

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

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

var table2 = format(triplets, 'blockid10', 'imageId');

var desc2 = 'table2_demo_' + link;
Export.table.toDrive({
  collection: table2, 
  description: desc2, 
  fileNamePrefix: desc2,
  fileFormat: 'CSV'
});

该示例来自 this presentation, linked from this page.