I have missing dates with no data which I want to create data for using linear interpolation. Most examples create a masked layer and replace the masked values but its my understanding that to interpolate for dates for which no data is available (temporal interpolation), one needs to create empty (fully masked) images for the months one want to create new data for. Struggling to add these empty dated images in image collection.

var roi = ee.Geometry.Rectangle([26, -24, 29, -27]);
// Import and filter dataset
var collection_GRACE = ee.ImageCollection('NASA/GRACE/MASS_GRIDS/LAND')
    .filter(ee.Filter.date('2002-01-01', '2016-12-31')) 
    .map(function(image){return image.clip(roi)})

// Print list of dates for which data is available
function ymdList(collection_GRACE){
    var iter_func = function(image, newlist){
        var date = ee.Number.parse(image.date().format("YYYYMMdd"));
        newlist = ee.List(newlist);
        return ee.List(newlist.add(date).sort());
    return collection_GRACE.iterate(iter_func, ee.List([]));

// Create/prepare collection of empty (fully masked) images for the months want to create new grids for
var monthsToInterpolate = ee.List([20020601,20020701,20030401]);
var initImages = monthsToInterpolate.map(function(dates) {
  var image = ee.Image().rename('lwe_thickness_csr').toFloat().set({
    'system:index': ee.Number(dates).format('YYYYMMdd'),
    'system:time_start': ee.Date(20020401). millis(),
  return image
var initCol = ee.ImageCollection.fromImages(initImages);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy