0

I'm having the problem of Tile error: Expected a homogeneous image collection, but an image with incompatible bands was encountered. Since number of total S-2 bands have changed during time, what can we do to solve this, when we don't even need to use that 2 new ones?

std all: Tile error: Expected a homogeneous image collection, but an image with incompatible bands was encountered:
  First image type: 21 bands ([B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, B12, AOT, WVP, SCL, TCI_R, TCI_G, TCI_B, QA10, QA20, QA60]).
Current image type: 23 bands ([B1, B2, B3, B4, B5, B6, B7, B8, B8A, B9, B11, B12, AOT, WVP, SCL, TCI_R, TCI_G, TCI_B, MSK_CLDPRB, MSK_SNWPRB, QA10, QA20, QA60]).
          Image ID: null
var datasetall = ee.ImageCollection('COPERNICUS/S2_SR')
                 .filterDate('2017-05-01', '2020-09-30')                  
                  .filterBounds(polygon);

var medall = datasetall.median();
var resultall = medall.select('B4', 'B8');
var ndviall = resultall.normalizedDifference(['B8', 'B4']);

var palette = ['FF0000', 'ffa500', 'FFFF00', '4CA64C', '207401'];

var stdall = medall.reduce(ee.Reducer.stdDev());

Map.addLayer(stdall.clip(polygon), {min: 0, max: 0.2, palette: palette}, 'std all');   

var ndvi_all = datasetall.map(
    function(img) {
         return img.normalizedDifference(['B8','B4'])
                  .rename('NDVI')
                  .copyProperties(img, ['system:time_start']);    });   
  
print(ui.Chart.image.series(ndvi_all, polygon, ee.Reducer.stdDev(), 10, 'system:time_start' ));
2

Use .select(bandNames) to select only the bands you need before the reduction (in the definition of datasetall).

var datasetall = ee.ImageCollection('COPERNICUS/S2_SR')
    .filterDate('2017-05-01', '2020-09-30')                  
    .filterBounds(polygon)
    .select([
      // Make this list whichever bands you want to view or analyze
      'B1', 'B2', 'B3', 'B4', 'B5', 'B6', 'B7', 'B8',
    ]);
1
  • Thanks a lot, it solved the problem! – Kenobi Obi-Wan Sep 15 '20 at 13:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.