根据 N D V I NDVI NDVI数据进行像元二分模型计算植被覆盖度
像元二分模型将像元的植被覆盖结构分为纯像元与混合像元两类,纯像元植被完全覆盖覆盖度为1,混合想要由植被与非植被构成,其 N D V I NDVI NDVI是植被覆盖部分的 N D V I NDVI NDVI值与非植被覆盖部分 N D V I NDVI NDVI值的线性加权:
N D V I = f v ⋅ N D V I v + ( 1 − f v ) ⋅ N D V I 0 NDVI=f_v\cdot NDVI_v+(1-f_v)\cdot NDVI_0 NDVI=fv⋅NDVIv+(1−fv)⋅NDVI0
其中 N D V I NDVI NDVI为像元 N D V I NDVI NDVI值, f v f_v fv为像元植被覆盖度, N D V I v NDVI_v NDVIv与 N D V I 0 NDVI_0 NDVI0分布式植被覆盖部分和非植被覆盖部分的 N D V I NDVI NDVI值,即为纯植被与纯裸地像元的 N D V I NDVI NDVI值,可得
f v = N D V I − N D V I 0 N D V I v − N D V I 0 f_v=\frac{NDVI-NDVI_0}{NDVI_v-NDVI_0} fv=NDVIv−NDVI0NDVI−NDVI0
通常情况取直方图累计频率为5%与95%的 N D V I NDVI NDVI值作为 N D V I 0 NDVI_0 NDVI0与 N D V I v NDVI_v NDVIv, N D V I ≤ N D V I 0 NDVI\le NDVI_0 NDVI≤NDVI0的像元植被覆盖度为0, N D V I ≥ N D V I v NDVI\ge NDVI_v NDVI≥NDVIv的像元植被覆盖都为1,在水体较多的区域为了避免水体面积过大对 N D V I v NDVI_v NDVIv与 N D V I 0 NDVI_0 NDVI0取值产生影响,可将水体去除( N D V I < 0 NDVI<0 NDVI<0)后再统计 N D V I NDVI NDVI直方图
var wuhan = ee.FeatureCollection("users/yp7454982/wuhan");
Map.addLayer(wuhan)
Map.centerObject(wuhan,8)
function maskS2clouds(image) {
var qa = image.select('QA60');
// Bits 10 and 11 are clouds and cirrus, respectively.
var cloudBitMask = 1 << 10;
var cirrusBitMask = 1 << 11;
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
.and(qa.bitwiseAnd(cirrusBitMask).eq(0));
return image.updateMask(mask).divide(10000);
}
var dataset_sentinel2=ee.ImageCollection("COPERNICUS/S2_SR")
.filterDate('2019-01-01','2019-12-31')
.filterBounds(wuhan)//
.filterMetadata('CLOUDY_PIXEL_PERCENTAGE',"less_than",20)
.map(maskS2clouds)
print(dataset_sentinel2)
筛选2019年在武汉市云量百分之20以下的所有数据,进行去云处理
var mid_image=dataset_sentinel2.median().clip(wuhan.geometry());
var visualization = {
min: 0.0,
max: 0.3,
bands: ['B4', 'B3', 'B2'],
};
Map.addLayer(mid_image,visualization,'RGB')
var NDVI=mid_image.normalizedDifference(["B8","B4"]).rename("NDVI")
print(NDVI)
Map.addLayer(NDVI.lt(0))//water
Map.addLayer(mid_image.updateMask(NDVI.gt(0)),visualization,'RGB1')
var mask_water_NDVI=NDVI.updateMask(NDVI.gt(0))//mask water
//var chart=ui.Chart.image.histogram(mask_water_NDVI,wuhan,100)
//print(chart)
function calFVC(BestVI,region,scale){
var num = BestVI.reduceRegion({
reducer:ee.Reducer.percentile([5,95]),
geometry:region,
scale:scale,
maxPixels:1e13
});
var min = ee.Number(num.get("NDVI_p5"));
var max = ee.Number(num.get("NDVI_p95"));
//print(top_min);
//print(top_max);
//quantile and combine
var greaterPart = BestVI.gt(max);
var lessPart = BestVI.lt(min);
var middlePart =ee.Image(1).subtract(greaterPart).subtract(lessPart);
//calculate FVC
var tempf1=BestVI.subtract(min).divide(max.subtract(min));
var FVC=ee.Image(1).multiply(greaterPart).add(ee.Image(0).multiply(lessPart))
.add(tempf1.multiply(middlePart))
return FVC.rename('FVC');
}
var FVC=calFVC(mask_water_NDVI,wuhan,10)
print(FVC)
var chart=ui.Chart.image.histogram({
image:FVC,
region:wuhan,
scale:250,
//maxPixels:1e13
})
print(chart)
Export.image.toDrive({
image: FVC,
description: "wuhan_fvc_2019",
scale: 10,
region: wuhan.geometry(),
maxPixels: 1e13
});