Cloudiest day of the year

Use MODIS to determine the cloudiest day of they year

step 1: Import the MOD09GA.005 Terra Surface Reflectance Daily L2G Global 1km and 500m

step 2: Draw a geometry

Step 3: use the code below:

// names of countries
var country_names = ['Myanmar (Burma)','Thailand','Laos','Vietnam','Cambodia']; // Specify name of country. Ignored if "use_uploaded_fusion_table" == y

// fusion table of countries
var countries = ee.FeatureCollection('ft:1tdSwUL7MVpOauSgRzqVTOwdfy17KDbw-1d9omPw');

var mekongCountries = countries.filter(ee.Filter.inList('Country', country_names));
var mekongRegion = mekongCountries.geometry();

// filter for date
terra = terra.filterDate(ee.Date.fromYMD(2000,1,1),ee.Date.fromYMD(2017,1,1));

// number of days in year
var days = ee.List.sequence(0,31,1);

// select the state_1km band
var img = ee.Image(terra.first()).select("state_1km");

// set clouds to 1 and add day of year
var clouds = {
      var im = ee.Image("state_1km")).eq(1033);
      var doy = ee.Date(img.get('system:time_start')).getRelative('day','year');
      return im.set("doy",doy).rename("clouds");

// sum all clouds for a day and divide by lenght of timeseries
var dailycloudcover =  ee.ImageCollection.fromImages( (d) {
    var l = clouds.filter(ee.Filter.eq('doy', d)).toList(500).length()
    var cc = ee.Image(clouds.filter(ee.Filter.eq('doy', d)).sum()).divide(l)
    return cc.set('doy',d)

// set viz parameter
var viz = {
  min: 0,
  max: 1,
  palette: '000000,0000FF,FDFF92,FF2700,FF00E7'

//show first map

// add the data as a chart
var chart = ui.Chart.image.seriesByRegion(dailycloudcover,

// print the chart

follow this link!


  1. Hi, It’s very interesting, but when I tried your code, but I get an error of memory limit exceeded each time (even without change anything).

Leave a Reply