0

I would like to filter ImColl based on the value of sum of clouded pixels; filter in script (not activated) doesn't do the job. And also the mapped cloud band is not the 'same' as reducer value, which is not error from code. Run the link to see outputs.

Can you help me solve this?

var start = '2020-02-15';
var end = '2020-02-18';
var viz = {min:0,max:0.8,palette:['#b88c0b','#cebc2d','ffd32c','#f7f217','f1ff33','d1ff4b','79ff6a','6beb4c','52b43a','#26a025']};

var MODIS_GAmap = ee.ImageCollection("MODIS/061/MOD09GA").filterDate(start);
Map.addLayer(MODIS_GAmap,{'bands':['sur_refl_b01','sur_refl_b04','sur_refl_b03'],min:30,max:1990},'rgb');
print(MODIS_GAmap,'maped');

var MODIS_GA = ee.ImageCollection("MODIS/061/MOD09GA")
                       .filterDate(start,end)
                       .map(function(i){
            var clip = i.clip(table);
            var QA = clip.select('state_1km');
            var cloud = ee.Image(QA.bitwiseAnd(1<<0).eq(1).rename('cloud'));
            var C_sum = cloud.reduceRegion({reducer:ee.Reducer.sum(),geometry:table,scale:500}).values();
            var ndvi   = clip.normalizedDifference(['sur_refl_b02', 'sur_refl_b01']).rename('NDVI_GA');
            
    return ee.Image([ndvi,cloud]).set('system:index',i.get('system:index'))
                                     .set('Cl_px_sum',C_sum)});//.filter(ee.Filter.lt('Cl_px_sum',75))});  //++DOESN'T WORK

print('Cloud px no.=', MODIS_GA.aggregate_array('Cl_px_sum')); //max study area=267 GA_px 
print(MODIS_GA);
Map.addLayer(MODIS_GA.select('cloud'),{},'cloud'); //++ reducer.sum returns value 0(cloudfree) for first date, but on map some values are 1    
Map.addLayer(MODIS_GA.select('NDVI_GA'),viz,'NDVI_GA');

link to code GEE:https://code.earthengine.google.com/08d65a0453ebf88d0fbda528f523d3f6

1 Answer 1

0

Problem solved.


var C_sum=cloud.reduceRegion({reducer:ee.Reducer.mean(),geometry:table,scale:500});
var C_sumN = C_sum.getNumber('cloud');
.................
    return ee.Image([ndvi, cloud]).set({'CLOUDINESS':C_sumN})});
..................
Map.addLayer(MODIS_GA.first().select('cloud'),{},'cloud');

Now the filter works. Yee yupi.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.