[GIS] How to combine bands and band ratios using earth engine

google-earth-enginemulti-bandpython

I am trying to display a multispectral image of bands (4,5,6,4/6,6/5) using Landsat8 satellite imagery. I am doing this in Google Earth Engine using Python. I am new to earth engine and python, so I am taking this as an important learning exercise.

For example, I would like something as intuitive as the following to work (where "test" is an image from Landsat8):

Image(url=test.getThumbUrl({
         'region':safata_region,
         'bands':'B4,B5,B6,B4/B6,B6/B5'
        }))

But it doesn't (If I were to remove the ratios B4/B6 and B6/B5 it works)

Creating the ratios of bands 4,5, and 6 is simple. For example:

A = test.expression(
'RED/SWIR',{
    'RED' : test.select('B4'),        
    'SWIR' : test.select('B6')
    }
)

B = test.expression(
'SWIR/NIR',{
    'NIR' : test.select('B5'),        
    'SWIR' : test.select('B6')
    }
)

But I cannot combine this with the other bands in the same fashion as above because A and B are not bands of "test"… I tried finding something similar in Google's fantastic guides, but no luck… Anyone able to give some guidance?

Best Answer

You need to add the bands to your image using, for instance, addBands.

var combined = test
               .addBands(A.rename('B4B6'))
               .addBands(B.rename('B5B6'));
Related Question