0

I'm trying to normalize data using the following function but i get an error that image collection does not have .multiply

def normalization_100(image,region,scale):
  mean_std = image.reduceRegion( ee.Reducer.mean()
            .combine(ee.Reducer.stdDev(),None, True),region,
  scale= scale,
  maxPixels = 10e9,
  tileScale= 16)
  
  def unit_(name):
      name = ee.String(name);
      band = image.select(name);
      mean=ee.Number(mean_std.get(name.cat('_mean')));
      std=ee.Number(mean_std.get(name.cat('_stdDev')));
      max=mean.add(std.multiply(3))
      min=mean.subtract(std.multiply(3))
      band1=ee.Image(min).multiply(band.lt(min)).add(ee.Image(max).multiply(band.gt(max))).add(band.multiply(ee.Image(1).subtract(band.lt(min)).subtract(band.gt(max))))
      result_band=band1.subtract(min).divide(max.subtract(min));
      return result_band#.toBands().rename(image.bandNames());

  
    

# // use unit scale to normalize the pixel values
  unitScale = ee.ImageCollection.fromImages(image.bandNames().map(unit_))#.multiply(10)
  
  return unitScale.multiply(100)
0

You cannot do band math on collections, only images. You would need to map a function over the collection, applying the scaling to each image.

return unitScale.map(function(img) { return img.multiply(100) })

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.