I would like to use a support vector regression model to predict a continuous outcome (percentage bareground cover). As predictors, I am using a number of different Landsat composite bands. Here is a selection of band values:

enter image description here

As you can see, the band values are on very different scales, which leads me to believe that they should be scaled for the regression model.

Here is an example of a Landsat image with band values of very different scale (e.g. Band 9 vs. Band 10): https://code.earthengine.google.com/?scriptPath=users%2Fjwiethase%2FTZ_restoration%3AUntitledFile2

Tried so far

It seems that a sensible scaling formula would be something like this:

scaled value = (x - mean(x)) / sd(x)

I know that I can apply some calculations to all bands of the image by using functions like .divide(), and calculate the average of a band using the reducer ee.Reducer.mean().


How do I put it all together, to apply the scaling function to every value in every band of an image?

The desired outcome is an image with the same number of bands and band values, but each value scaled based on the function using the respective band average and standard deviation.

1 Answer 1


To answer my own question:

We can apply a scaling function to the bands following the answer to this post:

var get_mean = my_image.reduceRegion({
  reducer: ee.Reducer.mean(),
  geometry: my_image.geometry(),
  scale: 30,
  maxPixels: 10e9

var get_sd = my_image.reduceRegion({
  reducer: ee.Reducer.stdDev(),
  geometry: my_image.geometry(),
  scale: 30,
  maxPixels: 10e9

var imaged_normalized = ee.ImageCollection.fromImages(
    name = ee.String(name);
    var band = my_image.select(name);
    return band.expression(
      '(x - mean_x) / sd_x', {
        'x': band,
        'mean_x': ee.Number(get_mean.get(name)),
        'sd_x': ee.Number(get_sd.get(name))})

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.