今天分享一下在GEE中如何计算湿度分量(wet),湿度的计算方法很简单,具体的公式为
Wet=(b20.1509+b30.1973+b40.3279+b50.3406+b6*(-0.7112)+b7*(-0.4572))/10000
其中b2,b3,b4,b5,b6,b7分别为影像的蓝波段、绿波段、红波段、近红波段、中红外波段 1、中红外波段 2
具体实现代码如下:
//导入自己的研究区,将其定义为roi
//选择山西省为研究区
var roi = ee.FeatureCollection("users/lilei655123/shanxi");
var star_date = '2020-06-01'//定义起始时间
var end_date = '2020-09-30'//定义终止时间
function rmL8Cloud(image) {
var cloudShadowBitMask = (1 << 3);
var cloudsBitMask = (1 << 5);
var qa = image.select('pixel_qa');
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
.and(qa.bitwiseAnd(cloudsBitMask).eq(0));
return image.updateMask(mask)
.copyProperties(image)
.copyProperties(image, ["system:time_start",'system:time_end']);
}
var L8_ = ee.ImageCollection("LANDSAT/LC08/C01/T1_SR").filterBounds(roi)
.filterDate(star_date, end_date)
.map(rmL8Cloud)
.mean()
.clip(roi)
print(L8_)
var img = L8_.clip(roi)
function sts_minmax (image){
var minmax = image.reduceRegion({
reducer: ee.Reducer.minMax(),
geometry:roi,
scale: 30,
maxPixels: 1e13}).values();
return minmax;}
//wet
var Wet1 = img.expression('B*(0.1509) + G*(0.1973) + R*(0.3279) + NIR*(0.3406) + SWIR1*(-0.7112) + SWIR2*(-0.4572)',{
'B': img.select(['B2']).multiply(0.0001),
'G': img.select(['B3']).multiply(0.0001),
'R': img.select(['B4']).multiply(0.0001),
'NIR': img.select(['B5']).multiply(0.0001),
'SWIR1': img.select(['B6']).multiply(0.0001),
'SWIR2': img.select(['B7']).multiply(0.0001)
})
var minMax = sts_minmax(Wet1);
var Wet = Wet1.unitScale(minMax.get(1),minMax.get(0))
//统计均值
var mean = Wet.reduceRegion({
reducer: ee.Reducer.mean(),
geometry:roi,
scale: 30,
maxPixels: 1e13
});
print(mean,'平均值')
//统计标准差
var rsei_std = Wet.reduceRegion({
reducer: ee.Reducer.stdDev(),
geometry:roi,
scale: 30,
maxPixels: 10e13
});
print(rsei_std,'标准差')//
//统计最大值
var max = Wet.reduceRegion({
reducer: ee.Reducer.max(),//
geometry:roi,//
scale: 30,//
maxPixels: 10e13//
});
print(max,'max')
//统计最小值
var min = Wet.reduceRegion({
reducer: ee.Reducer.min(),
geometry:roi,
scale: 30,
maxPixels: 10e13
});
print(min,'min')
Map.centerObject(roi,7)
var styling = {color:"red",fillColor:"00000000"};
Map.addLayer(roi.style(styling),{},"geometry")
Map.addLayer(Wet, {'min':0,'max':1,'palette':['0300ff', '418504', 'efff07', 'efff07', 'ff0303']}, 'Wet')
计算结果如下:
统计结果:
感谢关注,欢迎转发!
声明:仅供学习使用!