TransWikia.com

Removing a specific band from an image composite with hundreds of bands in Google Earth Engine

Geographic Information Systems Asked by user95904 on February 25, 2021

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:

Prevent glcmTexture() from generating the “_maxcorr” band
OR
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.

2 Answers

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()));

Correct answer by Kevin Reid on February 25, 2021

// 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

Answered by Muhammad Fawad Akbar Khan on February 25, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP