最近发现了一个巨牛的人工智能学习网站,点击跳转到网站:前言 – 床长人工智能教程
这个代码就是当我们再对影像进行插值对去云的影像进行弥补的时候,很多时候影像出不来结果,所以我们要改变我们的插值影像的时间,这样增加影像的时间,以便更多的影像用于插值。代码:
// define Dates
var startDate = ee.Date('2003-01-01')
var endDate = ee.Date('2021-12-31')
// Define another mask function to create mask from SmmaryQA
var maskQA = function(image) {
return image.updateMask(image.select("SummaryQA").eq(0)).multiply(0.0001)
.copyProperties(image, ['system:time_start'])
};
// Function for clip using the boundary
var clip = function(image){
return image.clip(ncr)
}
// Adding the MODIS 16 days NDVI collection and select NDVI, EVI, and DetailedQA: maskQA
var mask_col = ee.ImageCollection("MODIS/061/MYD13Q1")
.filterDate(ee.Date('2003-01-01'),ee.Date('2021-12-31'))
.filterBounds(ncr)
.select('NDVI', 'EVI', 'SummaryQA')
.map(maskQA)
.map(clip)
//.select('NDVI')
mask_col = mask_col.select('NDVI')
print(mask_col, 'original_masked_collection')
// selecting first NDVI and add to the map
// var image = ee.Image(filtered.first())
// .select('NDVI')
// // //.clip(ncr)
// Defing the palette for visualisation
var ndviVis = {min: 0, max: 0.7, palette: ['red', 'yellow', 'green', 'darkgreen']};
//Map.addLayer(image, ndviVis, 'ndvi')
Map.addLayer(mask_col.first().select('NDVI'), ndviVis, 'Mask1')
//##############################################################
// Step-2: Create an empty Time-Series images at n days interval
//##############################################################
// Select the interval. We will have 1 image every n days
var n = 16; // for repeativity of the date
var 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