1

Is it possible to merge two different dates to get the mean value of an image?

I am trying the following code, but at the end I don't get any result.

var clipToC1 = function(image){
  return image.clip(geometry)};


var AOD = ee.ImageCollection('MODIS/006/MCD19A2_GRANULES')
                  .select('Optical_Depth_055')
                  .filterDate('2019-01-01', '2019-02-01').merge('2019-11-01', '2020-01-01')
                  .map(clipToC1);
                  

var viz = {
  min: 0,
  max: 350,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
Map.addLayer(AOD.mean(), viz, 'Optical Depth 055');


  
 Export.image.toDrive({
   image:AOD.mean(), 
   folder: "Google EE results",
   description: 'jannovdez',
   scale: 1000,
   region:geometry 
      });
      

1 Answer 1

0

You can combine filters using ee.Filter.or():

  collection
    .filter(ee.Filter.or(
      ee.Filter.date('2019-01-01', '2019-02-01'),
      ee.Filter.date('2019-11-01', '2020-01-01')
    ))

You have another issue with your script. You're mapping over the collection and clipping each image to a geometry. That's very inefficient. Instead you want to filter the collection by the geometry and clip your final composite.

var geometry = Map.getBounds(true)

var AOD = ee.ImageCollection('MODIS/006/MCD19A2_GRANULES')
  .select('Optical_Depth_055')
  .filter(ee.Filter.or(
    ee.Filter.date('2019-01-01', '2019-02-01'),
    ee.Filter.date('2019-11-01', '2020-01-01')
  ))
  .filterBounds(geometry)
  
var composite = AOD.mean().clip(geometry)

var viz = {
  min: 0,
  max: 350,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
}

Map.addLayer(composite, viz, 'Optical Depth 055')

https://code.earthengine.google.com/e105d4ce63e7483e4d81b74985034316

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.