阵列排序对于获得自定义质量的mask很有用,这涉及根据不同波段中的值减少图像波段的子集。以下示例按云索引排序,然后获取集合中云最少的图像子集的平均值:
函数:
ee.Algorithms.Landsat.simpleCloudScore(image)
使用亮度、温度和 NDSI 的组合计算 [0,100] 范围内的简单的云似然分数。这不是一个多云的云检测器,主要用于比较同一点的多个外观以获取*相对*云可能性。
Computes a simple cloud-likelihood score in the range [0,100] using a combination of brightness, temperature, and NDSI. This is not a robust cloud detector, and is intended mainly to compare multiple looks at the same point for *relative* cloud likelihood.
Arguments:
image (Image):
The Landsat TOA image to process.
Returns: Image
代码:
// 将任意感兴趣区域定义为一个点。 var roi = ee.Geometry.Point(-122.26032, 37.87187); // 使用这些波段。 var bandNames = ee.List(['B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10', 'B11']); // 加载 Landsat 8 影像集合。 var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA') // 选择感兴趣的波段以避免占用内存。 .select(bandNames) // 过滤以仅获取感兴趣点的图像。 .filterBounds(roi) // 过滤以仅获取六个月的数据。 .filterDate('2014-06-01', '2014-12-31') // 通过在集合上映射 cloudMask 函数来屏蔽云。 // 这将为每个图像添加一个名为“cloud”的云尽心简单给这个点影像是否有云评分来对比。 .map(function(image) { return ee.Algorithms.Landsat.simpleCloudScore(image); }); // 将集合转换为数组。 var array = collection.toArray(); // 轴的标签。 var imageAxis = 0; var bandAxis = 1; // 获取云切片和感兴趣的波段。 var bands = array.arraySlice(bandAxis, 0, bandNames.length()); var clouds = array.arraySlice(bandAxis, bandNames.length()); // 按云量排序。 var sorted = bands.arraySort(clouds); // 获取最少混浊的图像,占总数的 20%。 var numImages = sorted.arrayLength(imageAxis).multiply(0.2).int(); var leastCloudy = sorted.arraySlice(imageAxis, 0, numImages); // 通过沿图像轴减少来获得最少云图像的平均值。 var mean = leastCloudy.arrayReduce({ reducer: ee.Reducer.mean(), axes: [imageAxis] }); // 将缩小后的阵列图像变成多波段图像进行显示。 var meanImage = mean.arrayProject([bandAxis]).arrayFlatten([bandNames]); Map.centerObject(roi, 12); Map.addLayer(meanImage, {bands: ['B5', 'B4', 'B2'], min: 0, max: 0.5});
影像结果:
