0

I'm trying to convert Kelvin to Celsius in MODIS LST product in Google Earth Engine. But there is an error in my code. The code is:

 var LST_K = ee.ImageCollection('MODIS/006/MOD11A2')
.filterBounds(AOI)
.filterDate('2021-02-20','2021-05-31')
.select("LST_Day_1km","LST_Night_1km")
.map(function(img){
  return img.multiply(0.02)
  .copyProperties(img,['system:time_start','system:time_end']);
});

print(LST_K);

// convert LST to celcius
var toCelsius = function(img){
var time = img.get('system:time_start')
var celsius = img.multiply(0.02) // scale factor
.subtract(273.15) // from kelvin to C
.rename('Celcius')
.set('system:time_start',time)
return celsius;
};
 
var LST = LST_K.map(toCelsius)
print(LST);

print(ui.Chart.image.series(LST, AOI, ee.Reducer.median(), 1000, 'system:time_start'));

and the link code is below: https://code.earthengine.google.com/61b7668525bd38cd543f72c0ad201886

Many thanks in advance

Gandom
  • 1
  • 2

1 Answers1

0

The error you're getting is about renaming the bands of the imageCollection "LST_K". This imageCollection has 2 bands, the LST_daytime band and the LST_nighttime band, so in your rename statement you should add two names instead of one.

Adding both names will solve this issue:

.rename(['LST_Day_1km_Celcius', 'LST_Night_1km_Celcius'])
CrossLord
  • 574
  • 4
  • 20