Skip to main content
added 8 characters in body
Source Link

Now instead of dailyday-time LST, I want to inlcudeinclude the LST_Night_1km band as well to create a time series of mean daily temperature. HowWhat would be the best way to proceed? Is there any way of perhaps creating an image collection with the mean of terraD and terraN and then using the "mean" band as independentthe dependent variable?

Now instead of daily LST, I want to inlcude the LST_Night_1km band as well to create a time series of mean daily temperature. How would be the best way to proceed? Is there any way of perhaps creating an image collection with the mean of terraD and terraN and then using the "mean" band as independent variable?

Now instead of day-time LST, I want to include the LST_Night_1km band as well to create a time series of mean daily temperature. What would be the best way to proceed? Is there any way of perhaps creating an image collection with the mean of terraD and terraN and then using the "mean" band as the dependent variable?

removed appreciation and thanks
Source Link
Vince
  • 20.3k
  • 16
  • 48
  • 65

Any help will be much appreciated. Thanks

Any help will be much appreciated. Thanks

Source Link

MODIS LST time series for daily average

I am trying to compute and plot the linear regression model for MODIS terra LST values. I have successfully plotted the "LST_Day_1km" band by using the following code:

var terraD = ee.ImageCollection('MODIS/061/MOD11A1')
  .filterDate('2020-01-01', '2020-06-01').select('LST_Day_1km')
  .filterBounds(geometry);

var terraN = ee.ImageCollection('MODIS/061/MOD11A1')
  .filterDate('2020-01-01', '2020-06-01').select('LST_Night_1km')
  .filterBounds(geometry);
  
//Set scene for map
Map.centerObject(geometry, 11);

//Add Buffer
var region = geometry.buffer(10000);
Map.addLayer(region, {color: "yellow"}, "Region");

//declare global time variable
var timefield = 'system:time_start'

//convert to degree celcius
var celcius =  terraD.map(function(image){
    return image.multiply(0.02)
    .subtract(273.15)
    .copyProperties(image, ['system:time_start'])
})


//Add variables for time series
var ND =  celcius.map(function(image){
    // Compute time in fractional years since the epoch.
  var date = ee.Date(image.get(timefield));
  var years = date.difference(ee.Date('1970-01-01'), 'year');//
  return image
    // Add a time band(Independant variable)
    .addBands(ee.Image(years).rename('t').float())
    //add a constant band (Independant Variable)
    .addBands(ee.Image.constant(1).rename('constant'))
})

//Linear Trend//==================

//independant variable names
var independants = ee.List(['constant', 't'])

//dependant variable name 
var dependant = ee.String('LST_Day_1km')

//Compute the betas using linear regression reducer.
var trend = ND.select(independants.add(dependant))
    .reduce(ee.Reducer.linearRegression(independants.length(), 1)) 
   
var coefficients = trend.select('coefficients')
    .arrayProject([0])
    .arrayFlatten([independants]);//naming the output bands the same name as variables
    
var LinearFitted = ND.map(function(image){
  return image.addBands(
    image.select(independants)
      .multiply(coefficients)
      .reduce('sum')
      .rename('Linearfitted'))
})    

// Plot the fitted model and the original data at the ROI.
print(ui.Chart.image.series(
  LinearFitted.select(['Linearfitted','LST_Day_1km']), region, ee.Reducer.mean(), 30)
    .setSeriesNames(['fitted', 'LST'])
    .setOptions({
      title: 'Linear Model: original and fitted values',
      lineWidth: 1,
      pointSize: 3,
}));

Now instead of daily LST, I want to inlcude the LST_Night_1km band as well to create a time series of mean daily temperature. How would be the best way to proceed? Is there any way of perhaps creating an image collection with the mean of terraD and terraN and then using the "mean" band as independent variable?

Any help will be much appreciated. Thanks