0

I have two ImagesCollections. I can do mean() reducer before merging them. But after merging them I got error when I was trying to do mean() to the merged imagecollection. See below the code.

//The image collection of Chlorophyll from MODIS Aqua
var chla_Modis = ee.ImageCollection("NASA/OCEANDATA/MODIS-Aqua/L3SMI")
.filterDate('2010-7-04', '2011-3-14')
.select('chlor_a');
print(chla_Modis);

var seawifsData = ee.ImageCollection("NASA/OCEANDATA/SeaWiFS/L3SMI");
var chla_SeaWiFS = seawifsData
.filterDate('2010-1-04', '2010-12-11')
.select('chlor_a');
print(chla_SeaWiFS);

//merge the two imageCollections
var mergedChla=chla_Modis.merge(chla_SeaWiFS);


print(mergedChla);

var meanChla=mergedChla.mean(); 
print(meanChla);
  • I copied and pasted your code exactly and there were no errors. You should always report any error messages so we can diagnose the problem. – Jon Apr 13 '18 at 14:56
  • If you change the second line from the bottom to var meanChla=mergedChla.mean(); You may get the error. – Sky Apr 13 '18 at 14:59
  • You should do that in your post. – Jon Apr 13 '18 at 15:02
  • You are right. I've changed the post. – Sky Apr 13 '18 at 15:06
1

You need to re-cast your merged imagecollection before calling mean(). Try this:

var meanChla=ee.ImageCollection(mergedChla).mean();

I can't explain why. I would guess it has something to do with the server-side not knowing that mergedChla is an ImageCollection.

  • My final goal is to combine the two data sets into one. As you can see there is one overlapped time period between the two data sets. I want get the mean value for each day in the overlapped time period and original value for each day not in the time period. Can you give me any advice? – Sky Apr 13 '18 at 15:48
  • What do you mean by "two data sets"? Are you saying that you only want to use the mean() reducer where they overlap? You should create a new question with as many details as possible. What do you want as an output? An ImageCollection or a single image or...? – Jon Apr 13 '18 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.