0

I am trying to normalize the values in each band across images in the imageCollection I have filtered.

I tried running this here

var normalized_collection = l1c_collection
  .filterDate(start_scene1, end_scene1)
  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 5))
  .map(function(my_image){
    var normalized_image = ee.ImageCollection.fromImages(
       my_image.bandNames().map(function(name){
         name = ee.String(name);
         var band = my_image.select(name);
         return band.expression(
           '(x * slope) + intercept', {
             'x': band,
             'slope': 0.0342,
             'intercept': 0.6494});
       })).toBands().rename(my_image.bandNames());
       return normalized_image;
});

However, the process returned an Error: User memory limit exceeded.

Is there a workaround to this?

1 Answer 1

2

There is no real need to first map across images, then across bands. Doing so can result in a large computational load on one node at Google Earth Engine's server-side.

It is better to use inbuilt functions which are innately parallelized on the server-side. In your case, you can use .multiply() and .add() since the slopes and intercepts are constant across images and bands.

This will look like the following:

var slope = 0.0342;
var intercept = 0.6494;
var normalized_collection = l1c_collection
  .filterDate(start_scene1, end_scene1)
  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 5))
  .map(function(image){
    return image.multiply(slope).add(intercept).copyProperties(image)
  })

The above code does not run into memory errors.

Link to complete code.

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.