Geographic Information Systems Asked by immarried on December 10, 2020
This question concerns the merging of the following Google Earth Engine collections:
I want to extend the “Landsat Simple Composite” example by loading similar collections from Landsat 5 and Landsat7, so that more years’ composites are available. I tried to first merge these three collections into a big one, before passing it to the Simple Composite algorithm:
// Composite 6 months of Landsat 8.
var l5 = ee.ImageCollection("LANDSAT/LT05/C01/T1");
var l7 = ee.ImageCollection("LANDSAT/LE07/C01/T1");
// Note that the input to simpleComposite is raw data.
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1');
var lall = ee.ImageCollection(l5.merge(l7).merge(l8));
// The asFloat parameter gives floating-point TOA output instead of
// the UINT8 outputs of the default simpleComposite().
var composite = ee.Algorithms.Landsat.simpleComposite({
collection: lall.filterDate('2015-1-1', '2015-7-1'),
asFloat: true
});
// Pick a spot with lots of clouds.
Map.setCenter(-47.6735, -0.6344, 12);
// Display a composite with a band combination chosen from:
// https://landsat.usgs.gov/how-do-landsat-8-band-combinations-differ-landsat-7-or-landsat-5-satellite-data
Map.addLayer(composite, {bands: ['B6', 'B5', 'B4'], max: [0.3, 0.4, 0.3]});
However, this returned the error:
Layer 1: Layer error: Image.visualize: No band named 'B6'. Available band names: [B1, B2, B3, B4, B5, B6_VCID_1, B6_VCID_2, B7, B8].
I see that the bands from these three collections are not the same, but on the other hand, l5.merge(l8)
runs with no errors. What’s the best way to merge these collections?
An option is to assign common names to the bands, here an example on a few bands:
// Assign a common name to the sensor-specific bands.
var LC8_BANDS = ['B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B10']; //Landsat 8
var LC7_BANDS = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B6_VCID_2']; //Landsat 7
var LC5_BANDS = ['B1', 'B2', 'B3', 'B4', 'B5', 'B7', 'B6']; //Llandsat 5
var STD_NAMES = ['blue', 'green', 'red', 'nir', 'swir1', 'swir2', 'temp'];
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA').select(LC8_BANDS, STD_NAMES)// Landsat 8
print(l8, 'Landsat 8')
var l7 = ee.ImageCollection('LANDSAT/LE07/C01/T1_TOA').select(LC7_BANDS, STD_NAMES) //Landsat 7
print(l7, 'Landsat 7')
var l5 = ee.ImageCollection('LANDSAT/LT05/C01/T1_TOA').select(LC5_BANDS, STD_NAMES) //Landsat 5
print(l5, 'Landsat 5')
var lall = ee.ImageCollection(l5.merge(l7).merge(l8));
print(lall, 'Merged')
There you will have the collections merged with no errors.
Answered by Oscar on December 10, 2020
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP