1

I am working with some modis LST data, and am running into the following problem:

I am running two functions on the data, which I will need to combine later. For that reason, the band names need to be the same. When I run the code below however, one output has band [LST_DAY_1km], and one has band [constant]. This obviously doesnt add up, and I am confused where the problem is coming from, given I'm using the same input data.

See code below:

    // Use the expression function to generate scaled LST.

var scaledlst1 = lst.map(function (lst) {
  return lst.expression(
    '(lst/30)',{
      'lst': lst.select('LST_Day_1km')
    });

});

Map.addLayer(scaledlst1, {band:'LST_Day_1km' ,max: 1 , min: 0}, 'scaledlst1');

//

var scaledlst2 = lst.map(function (lst) {
  return lst.expression(
    '(2.5-(0.05*lst))',{
      'lst': lst.select('LST_Day_1km')
    });

});

Map.addLayer(scaledlst2, {band:'LST_Day_1km', max: 1 , min: 0}, 'scaledlst2');

Does anyone have any suggestions as to why this might be?

My next step is to take the minimum value per pixel between the two products:

//select images

var ListOfImages1 = scaledlst1.toList(scaledlst1.size())
var ListOfImages2 = scaledlst2.toList(scaledlst2.size())


var LST = ee.Image(ListOfImages1.get(0))
var LST2 = ee.Image(ListOfImages2.get(0))


//Take min value
var scaledLST = ee.ImageCollection.fromImages([LST,LST2]).min()

Map.addLayer(scaledLST, {max: 1 , min: 0}, 'Scaled LST');

Which yields the following error:

Scaled LST: Tile error: Expected a homogeneous image collection, but an image with incompatible bands was encountered: First image type: 1 bands ([LST_Day_1km]). Current image type: 1 bands ([constant]). Image ID: 1 Some bands might require explicit casts.

1
  • 1
    Please Edit to include error messages as text in the body of the Question. Images are not searchable (or legible on all devices).
    – Vince
    Commented May 26, 2021 at 21:48

1 Answer 1

1

It seems that the "constant" band name arises because the second expression begins with a constant, which is treated as a single-band constant image. Note that with a small adjustment to your code, the resulting band names in scaledls2 is the expected "LST_Day_1km":

// Select a geometry for reproducibility
var geometry = ee.FeatureCollection('TIGER/2016/Counties')
  .filter(ee.Filter.eq('NAME', 'Waldo'));
print(geometry);
// Explicitly call dataset
var MOD = ee.ImageCollection("MODIS/006/MOD11A1");
var lst = MOD.filterDate("2019-01-01", "2019-02-01").filterBounds(geometry);
// First scaling operation
var scaledlst1 = lst.map(function (lst) {
  return lst.expression(
    '(lst / 30)',{
      'lst': lst.select('LST_Day_1km')
    });

});
print("scaledlst1",scaledlst1);
Map.addLayer(scaledlst1, {band:'LST_Day_1km' ,max: 1 , min: 0}, 'scaledlst1');

// Second scaling operation
var scaledlst2 = lst.map(function (lst) {
  return lst.expression(
    '(lst * (-0.05)) + 2.5',{
      'lst': lst.select('LST_Day_1km')
    });

});
print("scaledlst2",scaledlst2);
Map.addLayer(scaledlst2, {band:'LST_Day_1km', max: 1 , min: 0}, 'scaledlst2');

Also note Kevin Reid's discussion here on the tile error issue and how to work around that.

3
  • Thank you, that did remedy the band name issue! Ive taken a jab at the discussion you linked, but am receiving an error saying: Scaled LST: Layer error: Image.constant: Invalid Image.constant type. I tried: var LST = ee.Image.constant(ListOfImages1.get(0)).toFloat(); Commented May 26, 2021 at 22:27
  • Hmm, sounds like fodder for another question on gis.se. Folks like to limit posts to one question only around here. Commented May 26, 2021 at 22:39
  • Good to know! First time posting, thanks for the info! Commented May 26, 2021 at 22:41

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.