# 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 &quot;use_uploaded_fusion_table&quot; == 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(&quot;state_1km&quot;);

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

// sum all clouds for a day and divide by lenght of timeseries
var dailycloudcover =  ee.ImageCollection.fromImages(
days.map(function (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)
}).flatten())

// 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,
geometry,
ee.Reducer.mean(),
'clouds',
2500,
'doy',
'SITE');

// print the chart
print(chart);
```

1. Pauline says:

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).

1. Thanks! Try to adjust the time period (make it shorter).

1. Pauline says:

Not better, Have you got a special user statut?

2. Pauline says:

It’s work! Thanks you!