Search code examples
export-to-csvgoogle-earth-engine

Download daily mean AOD data GEE


I would like to download daily mean AOD data. I already did, but I got a file with 6015 rows and only ten rows with data, the rest of raws are empty.

enter image description here

How can I download only the data available?

var clipToCol = function(image){
  return image.clip(buff1k)};
var AOD = ee.ImageCollection('MODIS/006/MCD19A2_GRANULES')
                  .select('Optical_Depth_055')
                  .filterDate('2019-07-10', '2019-07-15').map(clipToCol);
                  //.filterBounds(RMSP);

var band_viz = {
  min: 0,
  max: 350,
  palette: ['black', 'blue', 'purple', 'cyan', 'green', 'yellow', 'red']
};
Map.addLayer(AOD.mean(), band_viz, 'Optical Depth 055');
var outline = ee.Image().byte().paint({
  featureCollection: buff1k,
  color: 1,
  width: 1
});

Map.addLayer(outline, {palette: ['black']}, 'buff1k');
Map.setCenter(-46.63203, -23.55221, 9);

 var AODmean_2 = AOD.map(function(img) {
   return img.reduceRegions({
       collection: buff1k,
       reducer: ee.Reducer.mean(),
        scale: 1000,
     }).map(function(f){
         return f.set('date', img.date());
     });
 }).flatten();
 Export.table.toDrive({
   collection:AODmean_2,
   folder: "Google EE results",
   selectors:(["date","mean"]),
   });

Solution

  • Use a notNull filter on the collection: change

    collection:AODmean_2,
    

    to

    collection: AODmean_2.filter(ee.Filter.notNull(["mean"])),