I am using Landsat 8 TOA imagery and noticed the BQA band has a smaller extent than the other bands. This results in gaps along the edges where there are no values. This is a problem for me because when I export a binary image masked with the BQA band, these gaps are automatically filled with zeroes and easily confused with real data zeroes. The desired behavior is for the BQA band to cover the same area as the other bands, so that all pixels can be masked properly.

Is this a known issue with Landsat imagery, or is it a GEE thing, that can be worked around?

Here is some code showing the problem:

var geometry = ee.Geometry.Point([-91.61831679448659,36.04036320483086])

// Get image
var scene = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA')
  .filterDate('2015-05-05', '2015-07-02')
  .filterMetadata('CLOUD_COVER', 'less_than', 10)

// Get cloud mask
var getQABits = function(image, start, end, newName) {
    var pattern = 0;
    for (var i = start; i <= end; i++) {
       pattern += Math.pow(2, i);
    // Return a single band image of the extracted QA bits, giving the band a new name.
    return image.select([0], [newName])

// A function to mask out cloudy pixels.
var clouds = function(image) {
  // Select the QA band.
  // var QA = image.select(['pixel_qa']);
  var QA = image.select(['BQA']);
  // Get the internal_cloud_algorithm_flag bit.
  return getQABits(QA, 4,4, 'Cloud').eq(0);
  // Return an image masking out cloudy areas.

// Create mask
var c = clouds(scene);

// Mask out clouds in image
var masked = scene.updateMask(c)

Map.addLayer(scene.geometry(), {color: 'red'}, 'original image extent')
Map.addLayer(masked, {}, 'masked image')
Map.addLayer(scene.select(1), {}, 'non-BQA band')
Map.addLayer(scene.select('BQA'), {}, 'BQA band')


In the code above, I make a cloud mask from the BQA band and the resulting raster image is smaller than the original Landsat 8 image.

The pixel_qa band in the surface reflectance product does not appear to have this problem, but ideally I would use TOA, so very curious why this is happening.

Your Answer

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

Browse other questions tagged or ask your own question.