1

Based on the MYD09GA QC_500m layer description below: MYD09GA LAYERS info QC_500m: 500m Reflectance Band Quality Bit 2-5: band 1 data quality four bit range 0000 (0): highest quality

I need to extract only the highest quality data of band1. My current code is given below as well. After applying the mask, when I try to generate a chart of the timeseries for Band1, I receive the error: Error generating chart: Data column(s) for axis #0 cannot be of type string. Is something wrong with my mask function? or I need to do any data transformation for the timeseries generation? Can anyone help out please. Many thanks

var mod = ee.ImageCollection("MODIS/006/MYD09GA"),
geometry1 = /* color: #d63000 */ee.Geometry.Point([10.644168108701706, 64.4188479841206]);

//Selecting Band 1 and QC layers
var dataset = mod.filterDate('2013-01-01', '2013-12-31').select('sur_refl_b01','QC_500m')
var single = dataset.first()

//create mask to extract only highest quality band 1 data 
var filter = function(image){ 
var mask = single.select('QC_500m').eq(0)
return ee.Image(image).updateMask(mask)
}
var maskapply = dataset.map(filter)
var chart = ui.Chart.image.seriesByRegion({
imageCollection: maskapply, 
regions: geometry1, 
reducer: ee.Reducer.mean(),
scale: 1000,
band: 'sur_refl_b01',
})
print(chart) 

1 Answer 1

4

Your mask was actually masking good quality pixels out, so there was no data to plot.

Changed mask to var mask = image.select('QC_500m').neq(0); // neq instead of eq Also, I think you want each mask to correspond to a particular image but not use one mask for the whole series like it was before.

So here's the new code:

var mod = ee.ImageCollection("MODIS/006/MYD09GA"),
geometry1 = /* color: #d63000 */ee.Geometry.Point([10.644168108701706, 64.4188479841206]);

//Selecting Band 1 and QC layers
var dataset = mod.filterDate('2013-01-01', '2013-12-31')
  .select('sur_refl_b01','QC_500m');

//create mask to extract only highest quality band 1 data 
var filter = function(image){ 
  var mask = image.select('QC_500m').neq(0);
  return ee.Image(image).updateMask(mask);
};

var maskapply = dataset.map(filter);

var chart = ui.Chart.image.seriesByRegion({
  imageCollection: maskapply, 
  regions: geometry1, 
  reducer: ee.Reducer.mean(),
  scale: 1000,
  band: 'sur_refl_b01',
});

print(chart);

and link to the code editor version

3
  • Thankyou Basile. :-)
    – user136891
    Mar 31, 2020 at 16:41
  • You're welcome. If it solved your problem, please mark it as an answer using grey/green checkmark on the left
    – Basile
    Mar 31, 2020 at 17:20
  • Hi Basile I have revisited the EE mask pages, and I think that if I was getting absolutely no data with using eq(0) in the mask, it actually meant there is no data with the quality ranking 0. Based on this explanation on EE page: var mask = datamask.eq(1); We use eq(1) to create a binary image in which all the pixels that do not have the value of 1 in the datamask band (those that are water or no data) get a value of 0 in the resulting image.
    – user136891
    Apr 17, 2020 at 14:17

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.