I have completed doing cloud removal with Landsat image (in this case is Lansat 8) in the Google Earth Engine. Of course the result of this process is the cloud pixels become no data, consequently the area which was as the cloud is perforated. I want to process this image to the nest step for classification and image transformation. So I want to fill the holey areas with no cloud data from other time period so that my study area has complete data within.

The result of cloud removal

How can I solve this problem as to fill the holey image? I use this cloud masking scirpt:

var roi = ee.Geometry.Point([97.90305, 3.98383]);

function maskL8sr(image) {
  // Bits 3 and 5 are cloud shadow and cloud, respectively.
  var cloudShadowBitMask = 1 << 3;
  var cloudsBitMask = 1 << 5;

  // Get the pixel QA band.
  var qa = image.select('pixel_qa');

  // Both flags should be set to zero, indicating clear conditions. 
  var mask1 = qa.bitwiseAnd(cloudShadowBitMask).eq(0)

  var mask2 = image.select('B.*').gt(0).reduce('min');

  // Return the masked image, scaled to TOA reflectance, without the QA bands.
  return image.updateMask(mask1.and(mask2)).divide(10000)
      .copyProperties(image, ["system:time_start"]);

var clipToCol = function(image){
  return image.clip(roi);

// Map the function over one year of data.
var collection = ee.ImageCollection('LANDSAT/LC08/C01/T1_SR')
    .filterDate('2019-01-01', '2019-12-31')

var composite = collection.reduce(ee.Reducer.percentile([25]));

// Display the results.
Map.addLayer(composite, {bands: ['B7_p25', 'B6_p25', 'B4_p25'], min: 0, max: 0.2});

How can I overcome this issue?

1 Answer 1


This example script may answer your question-

// Load a cloudy Landsat 8 image.
var image = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20130603');
         {bands: ['B5', 'B4', 'B3'], min: 0, max: 0.5},
         'original image');

// Load another image to replace the cloudy pixels.
var replacement = ee.Image('LANDSAT/LC08/C01/T1_TOA/LC08_044034_20130416');

// Compute a cloud score band.
var cloud = ee.Algorithms.Landsat.simpleCloudScore(image).select('cloud');

// Set cloudy pixels to the other image.
var replaced = image.where(cloud.gt(10), replacement);

// Display the result.
Map.centerObject(image, 9);
         {bands: ['B5', 'B4', 'B3'], min: 0, max: 0.5},
         'clouds replaced');

using whereyou can fill the cloud mask patches.

  • 1
    Can you please explain what "gt(10) is" is? Does this script work to replace no data (in case of cloud masking)? Sep 30, 2020 at 16:41
  • Check this link- code.earthengine.google.com/1394e2b405f4137b62ad39de6a882e1f .if I am correct cloud.gt(10) accounts for all the cloud cover present in an image. Oct 1, 2020 at 1:37
  • Thank you. any question else, how do you select replacement image? do you d it manually or using machine to select? Dec 25, 2020 at 13:41
  • by visual interpretation, replacement image was selected to fill the cloud removed locations. Dec 28, 2020 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.