GEE错误: Image.select: Band pattern ‘pixel_qa‘ did not match any bands. Available bands

目录

错误 

原始代码

 解决方案

修改后的代码

 结果


错误 

ImageCollection (Error)

Error in map(ID=LC08_138044_20220122): Image.select: Band pattern 'pixel_qa' did not match any bands. Available bands: [SR_B1, SR_B2, SR_B3, SR_B4, SR_B5, SR_B6, SR_B7, SR_QA_AEROSOL, ST_B10, ST_ATRAN, ST_CDIST, ST_DRAD, ST_EMIS, ST_EMSD, ST_QA, ST_TRAD, ST_URAD, QA_PIXEL, QA_RADSAT]

原始代码

var ROI = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[85.03450802623571, 23.669108838069914],
          [85.03450802623571, 21.60067630150156],
          [87.80306271373571, 21.60067630150156],
          [87.80306271373571, 23.669108838069914]]], null, false);
Map.centerObject(ROI);
//cloud mask
function maskL8sr(col) {
// Bits 3 and 5 are cloud shadow and cloud, respectively.
var cloudShadowBitMask = (1 << 3);
var cloudsBitMask = (1 << 5);
// Get the pixel QA band.
var qa = col.select('pixel_qa');
// Both flags should be set to zero, indicating clear conditions.
var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
             .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return col.updateMask(mask);
}

//vis params
var vizParams = {
  bands: ['SR_B5', 'SR_B6', 'SR_B4'],
  min: 642,
  max: 3307,
  gamma: [1, 0.9, 1.1]
};

var vizParams2 = {
  bands: ['SR_B4', 'SR_B3', 'SR_B2'],
  min: 0,
  max: 3000,
  gamma: 1.4,
};

//load the collection:
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
    .map(maskL8sr)
    .filterDate('2022-01-01','2022-02-27')
    .filterBounds(ROI)
    .map(function(image){return image.clip(ROI)});

print('coleccion', col);

//imagen reduction

var image = col.median();
print('image', image);

Map.addLayer(image, vizParams2);

//median
var ndvi1 = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
var ndviParams = {min: -0.2, max:0.7894295302013423, palette: ['blue', 'white', 'green']};

print('ndvi1', ndvi1);

//individual LST images

var col_list = col.toList(col.size());

var LST_col = col_list.map(function (ele) {
 
  var date = ee.Image(ele).get('system:time_start');

  var ndvi = ee.Image(ele).normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
 
  // find the min and max of NDVI
  var min = ee.Number(ndvi.reduceRegion({
    reducer: ee.Reducer.min(),
    geometry: ROI,
    scale: 30,
    maxPixels: 1e13
  }).values().get(0));

  var max = ee.Number(ndvi.reduceRegion({
    reducer: ee.Reducer.max(),
    geometry: ROI,
    scale: 30,
    maxPixels: 1e13
  }).values().get(0));

  var fv = (ndvi.subtract(min).divide(max.subtract(min))).pow(ee.Number(2)).rename('FV');
 
  var a= ee.Number(0.004);
  var b= ee.Number(0.986);
 
  var EM = fv.multiply(a).add(b).rename('EMM');

  var image = ee.Image(ele);

  var LST = image.expression(
    '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))-273.15', {
      'Tb': image.select('SR_B10').multiply(0.0000275),
      'Ep': fv.multiply(a).add(-0.2)
  });
  return ee.Algorithms.If(min, LST.set('system:time_start', date).float().rename('LST'), 0);

}).removeAll([0]);

LST_col = ee.ImageCollection(LST_col);

print("LST_col", LST_col);

/

Map.addLayer(ndvi1, ndviParams, 'ndvi');

//select thermal band 10(with brightness tempereature), no calculation
var thermal= image.select('SR_B10').multiply(-0.2);

var b10Params = {min: 291.918, max:302.382, palette: ['blue', 'white', 'green']};

Map.addLayer(thermal, b10Params, 'thermal');

// find the min and max of NDVI
var min = ee.Number(ndvi1.reduceRegion({
  reducer: ee.Reducer.min(),
  geometry: ROI,
  scale: 30,
  maxPixels: 1e13
}).values().get(0));

print('min', min );

var max = ee.Number(ndvi1.reduceRegion({
  reducer: ee.Reducer.max(),
  geometry: ROI,
  scale: 30,
  maxPixels: 1e13
}).values().get(0));

print('max', max);

//fractional vegetation
var fv = (ndvi1.subtract(min).divide(max.subtract(min))).pow(ee.Number(2)).rename('FV');

print('fv', fv);

//Map.addLayer(fv);

//Emissivity
var a= ee.Number(0.004);
var b= ee.Number(0.986);
var EM = fv.multiply(a).add(b).rename('EMM');

var imageVisParam3 = {min: 0.9865619146722164, max:0.989699971371314};

//Map.addLayer(EM, imageVisParam3,'EMM');

//LST in Celsius Degree bring -273.15
//NB: In Kelvin don't bring -273.15
var LST = col.map(function (image){

  var date = image.get('system:time_start');
 
  var LST = image.expression(
    '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))-273.15', {
    'Tb': thermal.select('SR_B11'),
    'Ep':EM.select('EMM')
  }).float().rename('LST');
 
  return LST.set('system:time_start', date);
 
});

print(LST);

Map.addLayer(LST, {min: 6.5, max: 39.9, palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
]},'LST');

print(
      ui.Chart.image.series({
        imageCollection: LST_col,
        region: ROI,
        scale: 30, // nominal scale Landsat imagery
        xProperty: 'system:time_start' // default
      }));
//export NDMI
 
Export.image.toDrive({
image: LST,
description: "exp_LST",
fileNamePrefix: "LST",
folder: "GEE_exp",
scale: 100,
region: ROI,
maxPixels: 1e13,
crs: "EPSG:32719"
});
 
 
 
 
 
 
 
 
 
 
 

 解决方案

这里我们是在进行Landsat C01和C02数据对于不同波段的命名造成的,所以这里我们很简单的就可以进行处理,因为GEE错误已经给出了提示。

这里还有一个问题,Landsat数据中的ST_10不是SR_10所以这里还会报错:

修改后的代码

var ROI = 
    /* color: #d63000 */
    /* displayProperties: [
      {
        "type": "rectangle"
      }
    ] */
    ee.Geometry.Polygon(
        [[[85.03450802623571, 23.669108838069914],
          [85.03450802623571, 21.60067630150156],
          [87.80306271373571, 21.60067630150156],
          [87.80306271373571, 23.669108838069914]]], null, false);
Map.centerObject(ROI);
//cloud mask
function maskL8sr(image) {
  // Bit 0 - Fill
  // Bit 1 - Dilated Cloud
  // Bit 2 - Cirrus
  // Bit 3 - Cloud
  // Bit 4 - Cloud Shadow
  var qaMask = image.select('QA_PIXEL').bitwiseAnd(parseInt('11111', 2)).eq(0);
  var saturationMask = image.select('QA_RADSAT').eq(0);

  // Apply the scaling factors to the appropriate bands.
  var opticalBands = image.select('SR_B.').multiply(0.0000275).add(-0.2);
  var thermalBands = image.select('ST_B.*').multiply(0.00341802).add(149.0);

  // Replace the original bands with the scaled ones and apply the masks.
  return image.addBands(opticalBands, null, true)
      .addBands(thermalBands, null, true)
      .updateMask(qaMask)
      .updateMask(saturationMask);
}

//vis params
var vizParams = {
  bands: ['SR_B5', 'SR_B6', 'SR_B4'],
  min: 642,
  max: 3307,
  gamma: [1, 0.9, 1.1]
};

var vizParams2 = {
  bands: ['SR_B4', 'SR_B3', 'SR_B2'],
  min: 0,
  max: 3000,
  gamma: 1.4,
};

//load the collection:
var col = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
    .map(maskL8sr)
    .filterDate('2022-01-01','2022-02-27')
    .filterBounds(ROI)
    .map(function(image){return image.clip(ROI)});

print('coleccion', col);

//imagen reduction

var image = col.median();
print('image', image);

Map.addLayer(image, vizParams2);

//median
var ndvi1 = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
var ndviParams = {min: -0.2, max:0.7894295302013423, palette: ['blue', 'white', 'green']};

print('ndvi1', ndvi1);

//individual LST images

var col_list = col.toList(col.size());

var LST_col = col_list.map(function (ele) {
 
  var date = ee.Image(ele).get('system:time_start');

  var ndvi = ee.Image(ele).normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
 
  // find the min and max of NDVI
  var min = ee.Number(ndvi.reduceRegion({
    reducer: ee.Reducer.min(),
    geometry: ROI,
    scale: 30,
    maxPixels: 1e13
  }).values().get(0));

  var max = ee.Number(ndvi.reduceRegion({
    reducer: ee.Reducer.max(),
    geometry: ROI,
    scale: 30,
    maxPixels: 1e13
  }).values().get(0));

  var fv = (ndvi.subtract(min).divide(max.subtract(min))).pow(ee.Number(2)).rename('FV');
 
  var a= ee.Number(0.004);
  var b= ee.Number(0.986);
 
  var EM = fv.multiply(a).add(b).rename('EMM');

  var image = ee.Image(ele);

  var LST = image.expression(
    '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))-273.15', {
      'Tb': image.select('ST_B10').multiply(0.0000275),
      'Ep': fv.multiply(a).add(-0.2)
  });
  return ee.Algorithms.If(min, LST.set('system:time_start', date).float().rename('LST'), 0);

}).removeAll([0]);

LST_col = ee.ImageCollection(LST_col);

print("LST_col", LST_col);

/

Map.addLayer(ndvi1, ndviParams, 'ndvi');

//select thermal band 10(with brightness tempereature), no calculation
var thermal= image.select('ST_B10').multiply(-0.2);

var b10Params = {min: 291.918, max:302.382, palette: ['blue', 'white', 'green']};

Map.addLayer(thermal, b10Params, 'thermal');

// find the min and max of NDVI
var min = ee.Number(ndvi1.reduceRegion({
  reducer: ee.Reducer.min(),
  geometry: ROI,
  scale: 30,
  maxPixels: 1e13
}).values().get(0));

print('min', min );

var max = ee.Number(ndvi1.reduceRegion({
  reducer: ee.Reducer.max(),
  geometry: ROI,
  scale: 30,
  maxPixels: 1e13
}).values().get(0));

print('max', max);

//fractional vegetation
var fv = (ndvi1.subtract(min).divide(max.subtract(min))).pow(ee.Number(2)).rename('FV');

print('fv', fv);

//Map.addLayer(fv);

//Emissivity
var a= ee.Number(0.004);
var b= ee.Number(0.986);
var EM = fv.multiply(a).add(b).rename('EMM');

var imageVisParam3 = {min: 0.9865619146722164, max:0.989699971371314};

//Map.addLayer(EM, imageVisParam3,'EMM');

//LST in Celsius Degree bring -273.15
//NB: In Kelvin don't bring -273.15
var LST = col.map(function (image){

  var date = image.get('system:time_start');
 
  var LST = image.expression(
    '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))-273.15', {
    'Tb': thermal.select('ST_B10'),
    'Ep':EM.select('EMM')
  }).float().rename('LST');
 
  return LST.set('system:time_start', date);
 
});

print(LST);

Map.addLayer(LST, {min: 6.5, max: 39.9, palette: [
'040274', '040281', '0502a3', '0502b8', '0502ce', '0502e6',
'0602ff', '235cb1', '307ef3', '269db1', '30c8e2', '32d3ef',
'3be285', '3ff38f', '86e26f', '3ae237', 'b5e22e', 'd6e21f',
'fff705', 'ffd611', 'ffb613', 'ff8b13', 'ff6e08', 'ff500d',
'ff0000', 'de0101', 'c21301', 'a71001', '911003'
]},'LST');

print(
      ui.Chart.image.series({
        imageCollection: LST_col,
        region: ROI,
        scale: 30, // nominal scale Landsat imagery
        xProperty: 'system:time_start' // default
      }));
//export NDMI
 
Export.image.toDrive({
image: LST,
description: "exp_LST",
fileNamePrefix: "LST",
folder: "GEE_exp",
scale: 100,
region: ROI,
maxPixels: 1e13,
crs: "EPSG:32719"
});
 
 
 

 结果

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

此星光明

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值