2

I want to calculate the NDVI index based on the MODIS/006/MCD43A4 collection and based on quality bands, but as a new GEE user I have no idea If I am on the rght way to do this. So far I have the following :

  var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
        //.select(['Nadir_Reflectance_Band2', 'Nadir_Reflectance_Band1'], ['NIR', 'RED']).multiply(0.0001)
        .filterBounds(geometry)
        .map(function(image){return image.clip(geometry)}) 
        .filter(ee.Filter.calendarRange(10,11,'month')),
    geometry = /* color: #d63000 */ee.Geometry.Polygon(
          [[[74.31655930070895, 56.84897198026647],
            [71.72378586320895, 53.54030739149663],
            [81.04019211320895, 51.563412328672136],
            [87.80777023820895, 55.429013452403986]]]);;


var modNDVI = imageCollection.select("Nadir_Reflectance_Band2","Nadir_Reflectance_Band1","BRDF_Albedo_Band_Mandatory_Quality_Band1","BRDF_Albedo_Band_Mandatory_Quality_Band2");


       var filterqa = function(feature){
     var image = ee.Image(feature);
     var QAImage = image.select(['BRDF_Albedo_Band_Mandatory_Quality_Band1']);
    var QAImage2 = image.select(['BRDF_Albedo_Band_Mandatory_Quality_Band2']);

     var maskedImage = ee.Image(0)
                         .where((QAImage.eq(0),1)&&(QAImage2.eq(0),1));

     return image.mask(maskedImage);  
};
var md_masked= modNDVI.map(filterqa);




        var ndvi = (function(image) {
          return image.expression('(NIR - RED) / (NIR + RED)', {
            'NIR': image.select('Nadir_Reflectance_Band2').multiply(0.0001).float(),
            'RED': image.select('Nadir_Reflectance_Band1').multiply(0.0001).float(),
          }).clamp(-1, 1);
        }); 

    print(imageCollection)


        //var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
        //Map.addLayer(, ndviParams, 'NDVI');

From the imageCollection, I see that each image has 14 bands from which, 7 (7-13) have quality information. How can I calculate the NDVI index based on the good quality observations? I am really confused as there is no a SummaryQA band simillar to the one from the MOD13Q1.

2

If you're interested in just using QA information from Bands 1 and 2, this should get you started. Note that most of the code below is the same as yours, just re-organized a bit. You're off to a great start! Also note that the final image collection contains 1159 images, and only the first of those is being added to the map in the final step.

var geometry = ee.Geometry.Polygon(
          [[74.31655930070895, 56.84897198026647],
            [71.72378586320895, 53.54030739149663],
            [81.04019211320895, 51.563412328672136],
            [87.80777023820895, 55.429013452403986]]);
Map.addLayer(geometry,{},"Geometry");

// Create NDVI function
var addNDVI = function(image) {
  var ndvi = image.normalizedDifference(["Nadir_Reflectance_Band2","Nadir_Reflectance_Band1"]);
  return image.addBands(ndvi.rename("NDVI"));
};

// Create a QA mask function
var filterqa = function(image){ 
  var mask1 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band1").eq(0);
  var mask2 = image.select("BRDF_Albedo_Band_Mandatory_Quality_Band2").eq(0);
  return image.updateMask(mask1).updateMask(mask2);
};

// Compile image collection and map relevant functions
var imageCollection = ee.ImageCollection("MODIS/006/MCD43A4")
        .filterBounds(geometry)
        .filter(ee.Filter.calendarRange(10,11,'month'))
        .map(filterqa)
        .map(addNDVI)
        .map(function(image){return(image.clip(geometry))});

print(imageCollection);
Map.addLayer(imageCollection.select("NDVI"),{},"Image");
  • 2
    thank you for your reply. I've managed to do it and your suggestion is very straightforward! Just a question though, what do you mean by saying "just using QA information from Bands 1 and 2"? Is not this the right way to control the quality of my NDVI since bands 1 and 2 are the bands that I use to calculate the index? – foo Feb 25 at 7:59
  • 1
    Many MODIS products have pixel reliability bands rather than individual band reliability layers. I don't have experience with the MCD43A4 but a cursory search online suggests that the approach above is the correct one. It would be in your best interest to have a good look through the documentation to confirm that is the case. – JepsonNomad Feb 25 at 16:03

Your Answer

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

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