从 Google Earth Engine 的图像集合中获取一组特定参数

Get an array of specific parameters from Image Collection of Google Earth Engine

我有一个像这样的图片集:

ImageCollection : {
  features : [
    0 : {
      type: Image,
      id: MODIS/006/MOD11A1/2019_01_01,
      properties : {
        LST_Day_1km   : 12345,
        LST_Night_1km : 11223,
        system:index  : "2019-01-01",
        system:asset_size: 764884189,
        system:footprint: LinearRing,
        system:time_end: 1546387200000,
        system:time_start: 1546300800000
      }, 
    1 : { ... }
    2 : { ... }
    ...
  ],
  ...
]

如何从这个集合中获取具有特定属性的对象数组?喜欢:

[
  {
    LST_Day_1km   : 12345,
    LST_Night_1km : 11223,
    system:index  : "2019-01-01"
  },
  {
    LST_Day_1km   : null,
    LST_Night_1km : 11223,
    system:index  : "2019-01-02"
  }
  ...
];

我试过ImageCollection.aggregate_array(property),但它一次只允许一个参数。

问题是“LST_Day_1km”的长度与“system:index”的长度不同,因为“LST_Day_1km”包含空值,所以get后很难合并数组他们分开。

提前致谢!

每当您想从 Earth Engine 中的集合中提取数据时,首先安排数据以 单个 属性 在该集合的 features/images 上,使用 map.

var wanted = ['LST_Day_1km', 'LST_Night_1km', 'system:index'];
var augmented = imageCollection.map(function (image) {
  return image.set('dict', image.toDictionary(wanted));
});

然后,正如您已经熟悉的那样,只需使用 aggregate_array 提取 属性 的值:

var list = augmented.aggregate_array('dict');
print(list);

可运行的完整示例:

var imageCollection = ee.ImageCollection('MODIS/006/MOD11A1')
    .filterDate('2019-01-01', '2019-01-07')
    .map(function (image) {
      // Fake values to match the question
      return image.set('LST_Day_1km', 1).set('LST_Night_1km', 2)
    });
print(imageCollection);

// Add a single property whose value is a dictionary containing
// all the properties we want.
var wanted = ['LST_Day_1km', 'LST_Night_1km', 'system:index'];
var augmented = imageCollection.map(function (image) {
  return image.set('dict', image.toDictionary(wanted));
});
print(augmented.first());

// Extract that property.
var list = augmented.aggregate_array('dict');
print(list);

https://code.earthengine.google.com/ffe444339d484823108e23241db04629