1

I'm trying to rename bands with standardized names across different Landsat sensors. When I add layers using visualization parameters for the new standardized band names, I get errors like this: "Layer error: Image.visualize: No band named 'SWIR1'. Available band names: [B1, B2, B3, B4, B5, B6, B7, B8, B9, B10, B11, BQA].", even though it appears the bands were renamed properly when I inspect the console. Any ideas how to fix this? Here's a link to the code I'm using: https://code.earthengine.google.com/4d18d66c8b83cdbfe8121face2de964a

//Collection filter parameters
var subset = Map.getBounds(true)
var start = '2019-12-01'
var end = '2020-02-28'

var colFilter = ee.Filter.and(
ee.Filter.bounds(subset),
ee.Filter.date(start, end),
ee.Filter.lt('CLOUD_COVER', 70)
)

//Visualization parameters
var vis = {      
  bands: ['SWIR1','NIR','Green'],
  min: 0,
  max: 0.5,
  gamma: [0.95, 1.1, 1]
};

// Assign a standard name to the sensor-specific bands.
var L8_BANDS = ['B2','B3','B4','B5','B6','B7','B10','BQA']; //Landsat 8 original names
var STD_NAMES = ['Blue', 'Green', 'Red', 'NIR', 'SWIR1', 'SWIR2', 'Thermal', 'BQA']; //Standard band names
var l8 = ee.ImageCollection('LANDSAT/LC08/C01/T1_TOA').select(L8_BANDS, STD_NAMES)// Rename bands

// Filter, sort, and print collection
var col = ee.ImageCollection(l8) 
 .filter(colFilter)
 .sort('DATE_ACQUIRED')
print(col, 'Landsat Collection')

// Display each image in collection
function addImage(image) { 
  var id = image.id;
  var iMage = ee.Image(image.id);
  Map.addLayer(iMage, vis, id);
}

// Use map on client-side
col.evaluate(function(col) {  
  col.features.map(addImage);
});
0

1 Answer 1

4
function addImage(image) { 
  var id = image.id;
  var iMage = ee.Image(image.id);
  Map.addLayer(iMage, vis, id);
}

When you do these steps, you're throwing out all information except the image's asset ID, and retrieving the original image by that ID — which has not had its bands renamed.

You could repeat the renaming on the fresh image:

  var iMage = ee.Image(image.id)
    .select(L8_BANDS, STD_NAMES);

Or instead, you could look up the image in the collection you modified:

  var iMage = col.filter(ee.Filter.eq('system:id', id)).first();

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.