十五
totalDays = endDate.difference(startDate, \''day\'');
var daysToInterpolate = ee.List.sequence(1, totalDays, n)
var initImages = daysToInterpolate.map(function(day) {
var image = ee.Image().rename(\''ndvi\'').toFloat().set({
\''system:index\'': ee.Number(day).format(\''%d\''),
\''system:time_start\'': startDate.advance(day, \''day\'').millis(),
// Set a property so we can identify interpolated images
\''type\'': \''interpolated\''
})
return image
})
var initCol = ee.ImageCollection.fromImages(initImages)
var mergedCol = ndviCol.merge(initCol)
//添加时间信息
var mergedCol = mergedCol.map(function(image) {
var timeImage = image.metadata(\''system:time_start\'').rename(\''timestamp\'')
var timeImageMasked = timeImage.updateMask(image.mask().select(0))
return image.addBands(timeImageMasked)
})
//第三步:利用Join函数把每个影像对应的之前和之后的影像链接起来。
//影像时间的转化
var days = 60
var millis = ee.Number(days).multiply(1000*60*60*24)
var maxDiffFilter = ee.Filter.maxDifference({
difference: millis,
leftField: \''system:time_start\'',
rightField: \''system:time_start\''
})
var lessEqFilter = ee.Filter.lessThanOrEquals({
leftField: \''system:time_start\'',
rightField: \''system:time_start\''
})
var greaterEqFilter = ee.Filter.greaterThanOrEquals({
leftField: \''system:time_start\'',
rightField: \''system:time_start\''
})
var filter1 = ee.Filter.and(maxDiffFilter, lessEqFilter)
var join1 = ee.Join.saveAll({
matchesKey: \''after\'',
ordering: \''system:time_start\'',
ascending: false})
var join1Result = join1.apply({
primary: mergedCol,
secondary: mergedCol,
condition: filter1
})
var filter2 = ee.Filter.and(maxDiffFilter, greaterEqFilter)