0

Why is it that when the following GEE code is used to calculate the lst of landsat8, the data statistics are correct, between 29°C and 55°C, but the output image is blank and the file is only 14.9MB?

https://code.earthengine.google.com/c69b5ae83bcb80b30341fbaacd365d22

// 载入你的区域
Map.addLayer(chifeng);

// 云、阴影遮蔽函数
function maskL8sr(col) {
  var cloudShadowBitMask = (1 << 3);
  var cloudsBitMask = (1 << 5);
  var qa = col.select('QA_PIXEL');
  var mask = qa.bitwiseAnd(cloudShadowBitMask).eq(0)
                 .and(qa.bitwiseAnd(cloudsBitMask).eq(0));
  return col.updateMask(mask);
}

// 可视化参数
var vizParams2 = {
  bands: ['SR_B4', 'SR_B3', 'SR_B2'],
  min: 0,
  max: 30000,
  gamma: 1.4,
};

// 载入影像集合
var coll = ee.ImageCollection('LANDSAT/LC08/C02/T1_L2')
  .map(maskL8sr)
  .filterDate('2019-01-01','2019-12-31')
  .filterBounds(chifeng);

// 打印原始影像集合
print(coll, 'rawcoll');

// 热红外波段校正函数
function calibrateTemperature(image) {
  var thermal = image.select('ST_B10');
  var temperature = thermal.multiply(0.1);
  return image.addBands(temperature.rename('Surface_Temperature'));
}

// 去除异常值函数
function removeOutliers(image) {
  var temperature = image.select('Surface_Temperature');
  var validRange = [-50, 70];
  var validTemperature = temperature.mask(temperature.gt(validRange[0]).and(temperature.lt(validRange[1])));
  return image.addBands(validTemperature.rename('Valid_Surface_Temperature'));
}

// 应用校正和去除异常值到影像集合
var calibratedcoll = coll.map(calibrateTemperature);
var processedcoll = calibratedcoll.map(removeOutliers);

// 打印处理后的影像集合
print(processedcoll);

// 影像降采样
var image = processedcoll.median();
print(image, 'image');
Map.addLayer(image, vizParams2);

// 计算 NDVI
var ndvi = image.normalizedDifference(['SR_B5', 'SR_B4']).rename('NDVI');
var ndviParams = {min: -1, max: 1, palette: ['blue', 'white', 'green']};
print(ndvi, 'ndvi');
Map.addLayer(ndvi, ndviParams, 'ndvi');

// 选择热红外波段
var newthermal = image.select('Valid_Surface_Temperature');
var b10Params = {min: -50, max: 70, palette: ['blue', 'white', 'green']};
Map.addLayer(newthermal, b10Params, 'newthermal');

// 计算 Fractional Vegetation
var minMax = ndvi.reduceRegion({
  reducer: ee.Reducer.minMax(),
  geometry: chifeng,
  scale: 30,
  maxPixels: 1e13
});

var min = ee.Number(minMax.get('NDVI_min'));
var max = ee.Number(minMax.get('NDVI_max'));

var fv = ndvi.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');

// 计算 Land Surface Temperature (LST)
var LST = newthermal.expression(
  '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))', 
  {
    'Tb': newthermal.select('Valid_Surface_Temperature'),
    'Ep': EM.select('EMM')
  }
).rename('LST');
Map.addLayer(LST, {min: -50, max: 70, 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');

// 将结果导出到 Google Drive
Export.image.toDrive({
  image: LST,
  description: "LST2019",
  scale: 30,
  region: chifeng,
  maxPixels: 1e13
});
1
  • Sorry, but after running the code changed by the expert, it is still a blank image with a file size of 14.9MB. i found that the problem seems to be with newthemal and lst, as these are the only two layers that don't show up on the online map! Commented Nov 14, 2023 at 4:52

1 Answer 1

1

I do not fully understand your code, but I see two main issues. In the first place, when calculating the temperature, you multiply by 0.1, but according with the documentation (https://developers.google.com/earth-engine/datasets/catalog/LANDSAT_LC08_C02_T1_L2#bands) that is not the way to go. You have to do it like this:

function calibrateTemperature(image) {
  var thermal = image.select('ST_B10');
  var temperature = thermal.multiply(0.00341802).add(149.0);
  return image.addBands(temperature.rename('Surface_Temperature'));
}

After applying this function, you have the temperature in kelvin. Therefore, your valid range cannot be [-50,70]. I suggest using [223, 343] which is equivalent.

function removeOutliers(image) {
  var temperature = image.select('Surface_Temperature');
  var validRange = [223, 343];
  var validTemperature = temperature.mask(temperature.gt(validRange[0]).and(temperature.lt(validRange[1])));
  return image.addBands(validTemperature.rename('Valid_Surface_Temperature'));
}

Secondly, LST is still empty because in your formula you need Ep, but Ep is not included in newthermal. You can create a combined ee.Image and apply the function to it.

var combined = ee.Image([newthermal, EM]);
// 计算 Land Surface Temperature (LST) with combined instead of newthermal
var LST = combined.expression(
  '(Tb/(1 + (0.00115* (Tb / 1.438))*log(Ep)))', 
  {
    'Tb': newthermal.select('Valid_Surface_Temperature'),
    'Ep': EM.select('EMM')
  }
).rename('LST');

Finally, you can visualize LST, but don’t forget to change the min and max:

Map.addLayer(LST, {min: 223, max: 343, palette: [ // hmsp
  '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');

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.