[GIS] Get a mask for MODIS (250m, MOD09GQ) using MODIS (500m, MOD09GA) in Google Earth Engine

cloud-gisgoogle-earth-enginemodis

How can I use the quality information stored in MODIS (500m) to create a mask for my MODIS (250m) image – e.g. cloud mask? When I merged the two image collections and run a function to detect the cloudy pixels, I got an error:

Error in map(ID=1_2018_01_01):
Image.select: Pattern 'state_1km' did not match any bands. My code:

// A function to mask out cloudy pixels.
var maskClouds = function(image) {
  // Select the QA band.
  var QA = image.select('state_1km')
  // Make a mask to get bit 10, the internal_cloud_algorithm_flag bit.
  var bitMask = 1 << 10;
  // Return an image masking out cloudy areas.
  return image.updateMask(QA.bitwiseAnd(bitMask).eq(0))
}
// Get a feature collection with Mexico boundary
var countries = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw')
var Mexico = countries.filter(ee.Filter.eq('Country', 'Mexico'));
var dataset = ee.ImageCollection('MODIS/006/MOD09GQ')
                  .filter(ee.Filter.date('2018-01-01', '2018-05-01'));
var terra = ee.ImageCollection("MODIS/006/MOD09GA"); 
var test = dataset.merge(terra)
.filterDate("2018-01-01", "2018-05-01");
var image = test
.filterBounds(Vietnam)
.map(maskClouds);

Best Answer

I think I found the solution. I changed the merge operator to combine and the code runs through:

var test = terra.combine(dataset).filterDate("2018-01-01", "2018-05-01"); 
Related Question