十五
var join2 = ee.Join.saveAll({
matchesKey: \''before\'',
ordering: \''system:time_start\'',
ascending: true})
var join2Result = join2.apply({
primary: join1Result,
secondary: join1Result,
condition: filter2
})
//第四步:利用线性插值先把空数据插出来。
var filtered = join2Result.filter(ee.Filter.eq(\''type\'', \''interpolated\''))
//定义插值函数
function interpolateImages(image) {
var image = ee.Image(image)
var beforeImages = ee.List(image.get(\''before\''))
var beforeMosaic = ee.ImageCollection.fromImages(beforeImages).mosaic()
var afterImages = ee.List(image.get(\''after\''))
var afterMosaic = ee.ImageCollection.fromImages(afterImages).mosaic()
var t1 = beforeMosaic.select(\''timestamp\'').rename(\''t1\'')
var t2 = afterMosaic.select(\''timestamp\'').rename(\''t2\'')
var t = image.metadata(\''system:time_start\'').rename(\''t\'')
var timeImage = ee.Image.cat([t1, t2, t])
var timeRatio = timeImage.expression(\''(t - t1) / (t2 - t1)\'', {
\''t\'': timeImage.select(\''t\''),
\''t1\'': timeImage.select(\''t1\''),
\''t2\'': timeImage.select(\''t2\''),
})
var interpolated = beforeMosaic
.add((afterMosaic.subtract(beforeMosaic).multiply(timeRatio)))
var result = image.unmask(interpolated)
return result.copyProperties(image, [\''system:time_start\''])
}
//进行时间插值,选择插值后的ndvi数据集,生成时间序列
var interpolatedCol = ee.ImageCollection(
filtered.map(interpolateImages)).select(\''ndvi\'');
var regularCol = interpolatedCol.filter(ee.Filter.eq(\''type\'', \''interpolated\''));
var interCol=regularCol.select(\''ndvi\'');
var chart = ui.Chart.image.series({
imageCollection: regularCol.select(\''ndvi\''),
region: geometry,
reducer: ee.Reducer.mean(),
scale: 20
}).setOptions({
tit