6

In Google Earth Engine, the function glcmTexture() outputs 18 types of texture bands. Out of these, one band (suffixed as _maxcorr) is actually not computed by the servers but still exists in the output as a GLCM band with all zero pixel values.

This _maxcorr band creates a problem when band-wise normalization of the image composite is attempted by the unitScale() function as this function requires min value to be less than the max value.

How to tackle this issue?

I thought of two possibilities:

  1. Prevent glcmTexture() from generating the "_maxcorr" band OR
  2. Remove "_maxcorr" band before input to unitScale() function

How to remove a specific band from an image in GEE? Trying reverse by using .select() function is not feasible as there are hundreds of other bands in the composite that need to be selected.

3 Answers 3

6

In order to remove particular bands from an image, you can take the image's bandNames, filter that list to only the bands you want, and select those bands from the image:

function removeMaxCorr(glcmImage) {
  return glcmImage.select(
    glcmImage.bandNames().filter(
      ee.Filter.stringEndsWith('item', '_maxcorr').not()));
}

Map.addLayer(removeMaxCorr(myImage.glcmTexture()));

(The pseudo-property name 'item' is the name used to refer to the value of a List item that isn't a feature with its own properties — here, a string.).

2
  • What is meant by 'item'?
    – cengstro
    Commented Feb 25, 2022 at 18:14
  • 1
    @cengstro It's the list item itself. I've added a link to the documentation. Thanks for pointing that out!
    – Kevin Reid
    Commented Feb 25, 2022 at 21:09
4
// Python Implementation for Removing bands
nameOfBands = image.bandNames().getInfo()
nameOfBands.remove("NameOfBandWhichYouWantToRemove")
print(nameOfBands) // Check if everything in order

image = image.select(nameOfBands) // Select all bands except the one you wanna remove
1
  • Ha - the Python one is so much more straightforward
    – fionag11
    Commented Sep 29, 2021 at 17:46
2

Javascript API solution for removing bands in list

var bandNames = image.bandNames()
var bandsToRemove = ['AOT','WVP']
var bandsToKeep = bandNames.removeAll(bandsToRemove)
print(image.select(bandsToKeep))

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.