2

我是谷歌地球引擎的新手,对javascript不太熟悉。我想按图层中的每个日期显示 Sentinel 2 的清除图像(B4、B3、B2 波段)(每个图层代表每个日期)。代码如下所示,但总是得到错误'no Band 4,constant band'。谁能帮我解决这个问题?谢谢!

var lakes=table.geometry();
Map.centerObject(lakes, 15);

function maskS2clouds(image) {
  var qa = image.select('QA60');

  // Bits 10 and 11 are clouds and cirrus, respectively.
  var cloudBitMask = 1 << 10;
  var cirrusBitMask = 1 << 11;

  // Both flags should be set to zero, indicating clear conditions.
  var mask = qa.bitwiseAnd(cloudBitMask).eq(0)
      .and(qa.bitwiseAnd(cirrusBitMask).eq(0));

  return image.updateMask(mask).divide(10000);
}

var start = ee.Date('2015-06-20');
var finish = ee.Date('2018-06-01');

var collection = ee.ImageCollection('COPERNICUS/S2')
                  .filterDate(start, finish)
                  .filterBounds(lakes)
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10))
                  .map(maskS2clouds);

var rgbVis = {
  min: 0.0,
  max: 0.3,
  bands: ['B4', 'B3', 'B2'],
};

function addImage(imageL) { // display each image in collection
  var id = imageL.id;
  var image = ee.Image(imageL.id);
  Map.addLayer(image.select(['B4','B3','B2']).clip(lakes),rgbVis,id)
}

collection.evaluate(function(collection) {  // use map on client-side
  print(collection.features);
  collection.features.map(addImage);
})
4

0 回答 0