我试图按云覆盖百分比(例如,20%)过滤Sentinel 2图像,然后对输出执行一些图像算术。
我正在尝试实现这里找到的内容:gis.stackexchange thread(https://gis.stackexchange.com/questions/303344/filter-landsat-images-cloud-cover)。不幸的是,功能ee.Algorithms.Landsat...
不适用于Sentinel 2图像,这是我正在做的事情所必需的。
到目前为止,我的代码如下。
var myCollection = ee.ImageCollection('COPERNICUS/S2');
var dataset2 = ee.ImageCollection(
myCollection.filterBounds(point) //use only one image that contains the POI
.filterDate('2015-06-23', '2019-04-25') //filter by date range
);
var ds2_cloudiness = dataset2.map(function(image){
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');
var cloudiness = cloud.reduceRegion({
reducer: 'median'
});
return image.set(cloudiness);
});
var filteredCollection = ds2_cloudiness.filter(ee.Filter.lt('cloud', 20));
Map.addLayer(filteredCollection, {min: -.2, max:.2}, 'test')
这会输出一个错误:Landsat.simpleCloudScore: Image is not a Landsat scene or is missing SENSOR_ID metadata.
在正确的方向任何轻推都会受到赞赏。
如果您只想使用云量百分比进行过滤,我认为有一种更简单的方法。您可以通过基于图像元数据进行过滤来完成此操作。
var myCollection = ee.ImageCollection('COPERNICUS/S2');
print(myCollection.first())
如果您检查Sentinel-2 imageCollection中的第一个图像,您实际上可以看到其元数据(仅适用于该图像)。因为,您正在使用同质且维护良好的图像集,您可以期望其他图像具有相似的特性。从这里,您可以执行以下操作
myCollection = myCollection.filter(ee.Filter.lte('CLOUDY_PIXEL_PERCENTAGE',20));
print(myCollection.first());
此特定代码将过滤图像集以查找云层小于或等于20的图像。您可以通过再次检查第一个图像或检查应缩小的集合大小来验证这一点。
但是,如果您正在寻找一个单独的算法来计算图像上的云,那么您可能必须为Sentinel编写一个算法(尚未)。