Below is a link to the code I've put together, but I am struggling with creating an updated cloud mask for Landsat collection 2 level 2 tier 1. I want to remove all cloudy pixels and mosaic all the images left in the image collection together.


// Filter image collectiton by bounds and geometry
var L7_2000 = ee.ImageCollection('LANDSAT/LE07/C02/T1_L2')
    .filterDate('2000-08-01', '2000-11-30')
    .filterMetadata('CLOUD_COVER','less_than', 50);
// Centre map canvas on geometry

// Apply scaling factors and add to map canvas
function applyScaleFactors(image) {
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBand = image.select('ST_B6').multiply(0.00341802).add(149.0);
  return image.addBands(opticalBands, null, true)
              .addBands(thermalBand, null, true);
L7_2000 = L7_2000.map(applyScaleFactors);

// Apply visulation parameters
var vis = {
  bands: ['SR_B3', 'SR_B2', 'SR_B1'],
  min: 0.0,
  max: 0.3,

// Print the number of images in image collection on to console

// Add image collection to map canvas remaining after filters and visualisation parameters applied
Map.addLayer(L7_2000, vis, 'True Color (321)');

1 Answer 1


There is an example of how to extract the cloud pixels from the QA band provided with the Landsat imagery and then make a composite here: https://code.earthengine.google.com/?scriptPath=Examples%3ACloud%20Masking%2FLandsat457%20Surface%20Reflectance

You can add your filters on the collection before applying the maskL457sr function to get your intended result.


Your Answer

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

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