1

I am wanting to merge Landsat 4, 5, 7, and 8 imagery. I need to adjust the Landsat 8 bands so that they match the other Landsat imagery bands. This is the basic structure of my code:

// L4 collection
var L4 = ee.ImageCollection("LANDSAT/LT04/C01/T1")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 59))
        .select(['B3', 'B2', 'B1']);     

// L5 collection
var  L5 = ee.ImageCollection("LANDSAT/LT05/C01/T2")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 59))
        .select(['B3', 'B2', 'B1']);

// l7 collection
var L7 = ee.ImageCollection("LANDSAT/LE07/C01/T1")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 58))
        .select(['B3', 'B2', 'B1']);   

// l8 collection
var L8 = ee.ImageCollection('LANDSAT/LC08/C01/T1')
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 58))
        .select(['B4', 'B3', 'B2', ],['B3', 'B2','B1']);

// Merge all
var collection = ee.ImageCollection(L4.merge(L5.merge(L7.merge(L8))));

// Map
Map.addLayer(collection, {bands:['B3', 'B2', 'B1'], min: 0, max: 3000}, 'collection_merge')

I've tried a couple of methods of changing bands for Landsat 8...

  return image.rename(['B0', 'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8', 'B9', 'B10', 'B11']);
})
.select(['B3', 'B2', 'B1']);
function renameBandsL8(image) {
    var bands = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'pixel_qa'];
    var new_bands = ['B', 'G', 'R', 'NIR', 'SWIR1', 'SWIR2', 'pixel_qa'];
    return image.select(bands).rename(new_bands);
}

and the latest

.select(['B4', 'B3', 'B2', 'B1'],['B5', 'B4', 'B3','B2'])

Nothing seems to be working and I can't figure out why.

Lola
  • 41
  • 2
  • 6

1 Answers1

0

You should convert all of your bands to a same format. The landsat-4,5,7 are in unsigned int8 format, while your landsat-8 is in unsigned int16 format. There are different way to handle this, one way is to convert your Landsat-8 to unsigned int8 format. Note that, I just modified the L8 collection part.

// L4 collection
var L4 = ee.ImageCollection("LANDSAT/LT04/C01/T1")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 59))
        .select(['B3', 'B2', 'B1']);     

// L5 collection
var  L5 = ee.ImageCollection("LANDSAT/LT05/C01/T2")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 59))
        .select(['B3', 'B2', 'B1']);

// l7 collection
var L7 = ee.ImageCollection("LANDSAT/LE07/C01/T1")
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 58))
        .select(['B3', 'B2', 'B1']);   

// l8 collection
var L8 = ee.ImageCollection('LANDSAT/LC08/C01/T1')
        .filter(ee.Filter.eq('WRS_PATH', 225))
        .filter(ee.Filter.eq('WRS_ROW', 58))
        .select(['B4', 'B3', 'B2', ],['B3', 'B2','B1'])
        .map(function(image){return image.toByte()});

// Merge all
var collection = ee.ImageCollection(L4.merge(L5.merge(L7.merge(L8))));
print(collection)
Map.addLayer(collection, {bands:['B3', 'B2', 'B1'], min: 0, max: 3000}, 'collection_merge')

Hope it helps.

HamiEbra
  • 310
  • 2
  • 7
  • Thanks Hami. I've edited my question so you can see the code that I am using. I do not understand how I can use var image = L8.toInt16() in this situation...could you please explain. – Lola May 22 '20 at 00:44