[GIS] time series NDVI – Modis products – GEE

google-earth-enginemodis

how can I select only good data (Quality informations) from Modis product in Google Earth Engine.
I tried use this code:

var collection = ee.ImageCollection ('MODIS/MYD13Q1').select(['NDVI'],['SummaryQA'] == 0).filterDate(ee.Date('2013-01-01'),ee.Date('2015-12-31'))
Map.addLayer(collection)

But this does not work

Best Answer

You need to mask all values where SummaryQA is not 0 in every image of your collection. This is done with a map in EarthEngine where you define a function to be applied to each image in your collection. You then create a new collection by mapping this function over every image in your old collection. goodCollection then only contains observations marked as "Good Data".

var collection = ee.ImageCollection ('MODIS/MYD13Q1')
  .filterDate(ee.Date('2013-01-01'),ee.Date('2015-12-31'))

//function to create mask from SmmaryQA
var maskQA = function(image) {
  return image.updateMask(image.select("SummaryQA").eq(0));
};

var goodCollection = collection.map(maskQA)