1

I input each image and band and, created an Image Collection in GEE. However, each band is as "b1" and I want to rename in order that I created the Image Collection respectively as b1,b2,b3 and b4 .

I am trying as:

var mar_03 = ee.ImageCollection("users/nayaraestrabis/collection")
            .select(ee.Image("users/nayaraestrabis/collection/image_band2")).select('b1').rename('b2')

and it didn't work. I am trying to do a function, but I don't know how to do using an Image Collection.

1 Answer 1

2

Since you're working over an ImageCollection, you must use map() to iterate name changing over the entire collection. This is an example with Landsat scenes:

var landsat = ee.ImageCollection("LANDSAT/LO08/C01/T1");

print(landsat.first().bandNames());

//["B1","B2","B3","B4","B5","B6","B7","B8","B9","BQA"]

var changeNames = function(img){
  return img.select(['B1','B2','B3','B4'],['Band1','Band2','Band3','Band4']);
}

var landsatNewNames = landsat.map(changeNames);

print(landsatNewNames.first().bandNames());

//["Band1","Band2","Band3","Band4"]

I created changeNames() function for this purpose. Since this is an example, I only selected 4 bands changing names, consider selecting all bands needed

1
  • Thank you so much!! Your example helped me a lot =) Obrigada!!
    – Nayara E.
    Commented Mar 18, 2021 at 19:43

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.