与图像一样,有多种方法可以获取有关 ImageCollection
. 集合可以直接打印到控制台,但控制台打印输出限制为 5000 个元素。超过 5000 张图像的集合需要在打印前过滤。打印大集合会相应地变慢。以下示例显示了以编程方式获取有关图像集合的信息的各种方法:此次需要用到以下几个东西大家先看看:=
reduceColumns(reducer, selectors, weightSelectors)
将 reducer 应用于集合的每个元素,使用给定的选择器来确定输入。
返回结果字典,以输出名称为键。
Apply a reducer to each element of a collection, using the given selectors to determine the inputs.
Returns a dictionary of results, keyed with the output names.
this:collection (FeatureCollection):
The collection to aggregate over.
reducer (Reducer):
The reducer to apply.
selectors (List):
A selector for each input of the reducer.
weightSelectors (List, default: null):
A selector for each weighted input of the reducer.
ee.Reducer.minMax()
返回一个 Reducer,用于计算其输入的最小值和最大值。
Returns a Reducer that computes the minimum and maximum of its inputs.
aggregate_stats(property)
聚合集合中对象的给定属性,计算所选属性的总和、最小值、最大值、平均值、样本标准偏差、样本方差、总标准偏差和总方差。
Aggregates over a given property of the objects in a collection, calculating the sum, min, max, mean, sample standard deviation, sample variance, total standard deviation and total variance of the selected property.
this:collection (FeatureCollection):
The collection to aggregate over.
property (String):
The property to use from each element of the collection.
代码:
//加载影像并且以行列号的形式搜索影像并进行时间筛选最后打印出影像信息
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
.filter(ee.Filter.eq('WRS_PATH', 44))
.filter(ee.Filter.eq('WRS_ROW', 34))
.filterDate('2014-03-01', '2014-08-01');
print('Collection: ', collection);
// 统计影像的数量
var count = collection.size();
print('Count: ', count);
// 从影像集合中获取影像时间的范围并且进行打印看看效果
var range = collection.reduceColumns(ee.Reducer.minMax(), ["system:time_start"])
print('Date range: ', ee.Date(range.get('min')), ee.Date(range.get('max')))
// 在集合中获取影像的属性值
var sunStats = collection.aggregate_stats('SUN_ELEVATION');
print('Sun elevation statistics: ', sunStats);
// 获取影像的集合并进行云量筛选,获取云量最少的一幅
var image = ee.Image(collection.sort('CLOUD_COVER').first());
print('Least cloudy image: ', image);
// 在时间上进行影像筛选获取获取最新的影像
var recent = collection.sort('system:time_start', false).limit(10);
print('Recent images: ', recent);