今天分享一下如何在GEE中计算整年影像的可用数量。

在阅读文献的过程中,发现在使用GEE处理影像时,都会说明某年到某年有多少景影像,处理了多少景。

我也想知道在自己的研究区里有多少景可用的影像

以宁夏为例

GEE代码如下:

var roi = ee.FeatureCollection("users/guaicai666666/Ningxia");
var l8_sr = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR")
.filter(ee.Filter.lt('CLOUD_COVER',5))
var Landsat8 = {
scaleImage: function(image) {
var time_start = image.get("system:time_start");
image = image.select(["B2","B3","B4","B5","B6","B7"]);
image = image.divide(10000);
image = image.set("system:time_start", time_start)
return image;
},
getL8SRCollection : function(startDate, endDate, roi) {
var dataset = l8_sr.filterDate(startDate, endDate)
.filterBounds(roi)
.map(Landsat8.scaleImage)
return dataset;
}
};
//生成逐年
function processYearImage(year, region,data_list) {
var startDate = ee.Date.fromYMD(year, 1, 1);
var endDate = ee.Date.fromYMD(year+1, 1, 1);
var l8 = Landsat8.getL8SRCollection(startDate, endDate, region);
var Imgs = l8
var imgSize = Imgs.size();
print("可用影像"+year,imgSize);
var imgCount= Imgs.select("B2").map(function(img){
return img.multiply(0).add(1).toInt();
}).sum().clip(roi);
var visParam = {
min: 10,
max: 40,
palette: 'FFFFFF, CE7E45, DF923D, F1B555, FCD163, 99B718, 74A901, 66A000, 529400,' +
'3E8601, 207401, 056201, 004C00, 023B01, 012E01, 011D01, 011301'
};
Map.addLayer(imgCount,visParam,"imgCount"+year);
var temp_feature=ee.Feature(null,null);
temp_feature = temp_feature.set('year', year);
temp_feature = temp_feature.set('imgSize', imgSize);
data_list.push(temp_feature)
}
//循环导出所有影像可用图
function main() {
//开始年份和结束年份
var startYear =2013;
var endYear = 2021;
var data_list=[]
for (var year=startYear; year<=endYear; year++) {
processYearImage(year, roi,data_list);
}
var featureCollection = ee.FeatureCollection(data_list);
//导出谷歌云盘
Export.table.toDrive({
collection: featureCollection,
description: 'imgsize',
fileFormat: 'CSV'
});
print(data_list)
}
main();

计算结果:

Google Earth Engine(GEE)显示影像可用数量_java

Google Earth Engine(GEE)显示影像可用数量_大数据_02

感谢关注,欢迎转发!

声明:仅供学习使用!

GEE demo:

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

**更多内容请关注微信公众号“生态遥感监测笔记”