I run into an error when merging 2 image collections.
Goal: I want to merge the (identical) 250m daily Terra and Aqua MODIS collections into one image collection to obtain one collection with 2 images per day:
// ------MODIS 250M DAILY ----------------------------------------------
var modis_250m_daily_terra = modis_250m_daily_terra.filterBounds(aoi).filterDate(date_start,date_end);
var modis_250m_daily_aqua = modis_250m_daily_aqua.filterBounds(aoi).filterDate(date_start,date_end);`
Method to merge the collections:
>`// ------MERGE MODIS 250M DAILY ----------------------------------------------
var modis1 = modis_250m_daily_terra.merge(modis_250m_daily_aqua);
// sort by date
var modis1 = modis1.sort("system:time_start");
print('MODIS Surface Reflectance Daily 250m',modis1);
var size_modis1 = modis1.filterBounds(aoi).filterDate(date_start,date_end).toList(100000).length();
print('Total images in modis1 (250m daily) in current time frame: ', size_modis1);
print('Merged 250m MODIS',modis1);
This seems to work until in the following function, this code runs into an error "Invalid argument specified for ee.List(): sur_refl_b01", whereas this function used to work without the merge.
// ------CLOUDFUNCTION----------------------------------------------------
var cloudfunction = function(image){
//filter the image on its high reflectance part
var cloud = image.select('sur_refl_b01').rename('cloud');
var cloud01 = cloud.gt(1000).lt(4000);
image = image.updateMask(cloud01).addBands(cloud);
var area = ee.Image.pixelArea();
var cloudArea = cloud01.multiply(area).rename('cloudArea');
image = image.addBands(cloudArea);
var stats = cloudArea.reduceRegion({
reducer: ee.Reducer.sum(),
geometry: aoi,
scale: 250,
});
return image.set(stats);
};
var collection = modis1.map(cloudfunction);
print ('Clouds pixels', collection);
I tried a way to 'join' the collections instead, but this doesn´t give the semidiurnal image collection. Any ideas on how to either avoid the error, or to improve the merge that I applied?