In the below code I want to get mean precipitation value but returns error. I don't know why this happened?

enter image description here

code link: https://code.earthengine.google.com/e8deb9034f8384dca2cd0f132445e199

var starting = '2018-05-01';
var ending = '2018-10-01';
var year = '2018';

var temporalCollection = function(collection, start, count, interval, units){
  var sequence  = ee.List.sequence(0, ee.Number(count).subtract(1));
  var originDate = ee.Date(start);
  return ee.ImageCollection(sequence.map(function(i){
    var startDate  = originDate.advance(ee.Number(interval).multiply(i), units);
    var endDate = originDate.advance(ee.Number(interval).multiply(ee.Number(i).add(1)), units);
    return collection
    .filterDate(startDate, endDate).mean().clip(table)
    .set('system:time_end', endDate.millis());

var pre = function(img){
  var bands = img.select('precipitationCal').clip(table).multiply(24.0);
  return bands

var GPM = ee.ImageCollection("NASA/GPM_L3/IMERG_V06")
.filterDate(starting, ending)

var GPMdaily = temporalCollection(GPM, starting, 153, 1, 'days')
  var bandsStdv = img.reduceRegion({
    reducer: ee.Reducer.stdDev(),
    geometry: table,
    scale: 10000
  var bandsMean = img.reduceRegion({
    reducer: ee.Reducer.mean(),
    geometry: table,
    scale: 10000
  var id = ee.Date(img.get('system:time_start')).format('yyyy-MM-dd');
  return img.rename(id)
  .set('bandsMean', bandsMean)
  .set('bandsStdv', bandsStdv)


// this part returns error

var class0 =GPMdaily
.filter(ee.Filter.metadata('bandsMean','less_than', 1.1));

var class0Per = GPMdaily
.filter(ee.Filter.gt('bandsMean', 1.1))

var class1PerMean  = class0Per.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: table,
  scale: 10000, 
  bestEffort: true


1 Answer 1


Lots of operations on ImageCollections expect/need all of the images to have the same number of bands with the same names and types. In your code, you're renaming the output bands (in the second .map()) to reflect the time of the first image in each mean, giving them different names, and the mean() on line 73 doesn't know what to do with that.

Just skip the renaming; you're just taking a mean and not doing anything with the names.

Your Answer

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

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