0

How to normalize a stack of features in the google earth engine? Features are the image type you can see the Javascript code here. I'm going to normalize features between 0,1 values.

Can you provide suggestions and snippets?

var ***features*** = (feature 1

    .addBands(feature 2)
    .addBands(feature 3)
    .addBands(feature 4) 
    .addBands(feature 5)
    .addBands(feature 6)
    .addBands(feature 7)
    .addBands(feature 8)
    .addBands(feature 9)
    .addBands(feature 10)
    .addBands(feature 11)
    .addBands(feature 12)
    .addBands(feature 13)
    )
4
  • What are you trying to accomplish? Can you provide a working sample code to show what you want to convert?
    – JonasV
    Commented Nov 25, 2020 at 10:12
  • This is exactly what i want to do! Each feature is an image. Commented Nov 25, 2020 at 10:21
  • Do you want to normalize across the image stack or for each band individually?
    – JonasV
    Commented Nov 25, 2020 at 11:33
  • For each band individiually. All the bands(images) have has the same size. Commented Nov 25, 2020 at 12:13

1 Answer 1

0

Normalization is simple all you have to do is find min and max value per band and normalize each band. Below is the code for doing so, add this in a map function to apply it for every band. Function useful here in unitScale.

Note: it does not clamp the values greater than 1 which means if you specify the wrong max value the normalized values can be greater or smaller than 1.

// Stats will have min max for every band
var stats = image.reduceRegions({
   collection: image.geometry(),
   reducer: ee.Reducer.minMax(),
   scale: //your image scale,
});

print(ee.Feature(stats));

// Normalizing just B1
var norm_image = image.select('B1')
                 .unitScale(stats.get('B1_min'),stats.get('B1_max'))
1
  • Thank you for your response. How can I add to map function to apply it for every band? Commented Dec 21, 2020 at 10:03

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.