S-G滤波算法主要是用来进行数据平滑使用,一种基于平滑时间序列数据和最小二乘原理的卷积算法,采用移动窗口的加权平均算法,但其加权系数不是简单的常数窗口,而是通过在滑动窗口内对给定高阶多项式的最小二乘拟合得出,关于S-G滤波算法网上有很多的文献,这里主要介绍在GEE平台上进行应用,代码如下:
var oeel=require('users/OEEL/lib:loadAll');
modis=modis.filterDate('2020-01-01','2020-12-31').filterBounds(roi);
print(ui.Chart.image.series(modis.select('NDVI'), roi, ee.Reducer.mean(), 1000));
var SG=oeel.ImageCollection.SavatskyGolayFilter(modis,
ee.Filter.maxDifference(1000*3600*24*32, 'system:time_start', null, 'system:time_start'),
function(infromedImage,estimationImage){
return ee.Image.constant(ee.Number(infromedImage.get('system:time_start'))
.subtract(ee.Number(estimationImage.get('system:time_start'))));},
3,['NDVI']);
print(SG)
print('Smoothed data',ui.Chart.image.series(SG.select('d_0_NDVI'), roi, ee.Reducer.mean(), 1000));
print('Smoothed data',ui.Chart.image.series(SG.select('d_1_NDVI'), roi, ee.Reducer.mean(), 1000));
var area_ndvi=SG.select('d_0_NDVI').filterDate('2020-01-01', '2020-12-31').max().clip(roi).reproject('EPSG:4326', null, 250);
print(area_ndvi)
Export.image.toDrive({
image:area_ndvi,
description: "2020",
fileNamePrefix: "2020",
scale: 250,
region: roi,
folder: "Third",
maxPixels: 1e13
});
modis和roi分别为数据集合和研究区,同样,此方法也可应用于Landsat系列影像和哨兵-2等光学影像,加入NDVI波段即可。
未平滑结果和平滑结果如下所示: