1

How to perform computations on two image collections( here e0 and Ts). I have to use the formula RL_up = stfn*e0*T^4 for computing the long wave radiation.

//outgoing long wave radiation 
var stfn = 5.67/100000000;

var Ts = surfacetemp.filterBounds(ROI).filterDate( '2018-01-01', '2018-12-31').sort('system:time_start', false);

var lai = LAI.filterBounds(ROI).filterDate( '2018-01-01', '2018-12-31').sort('system:time_start', false);

print(Ts);
//Map.addLayer(Ts);
var e0 = function(image){
  var e01 = image.expression(
  "0.95 + 0.01*lai",
  {
    'lai': image.select('LAI'),

  });`
  return(image.addBands(e01.rename("E0")));
};

var dataset = LAI
                  .filterDate('2018-01-01', '2018-12-31')
                  .filterBounds(ROI)
                  .map(e0);

print("dataset",dataset);

var e0 = dataset.select("E0"); // To isolate just the albedo band
print("e0",e0); // Look at it


//Long wave radiation 
var RL_up = function(image){
  var RL = image.expression(
  "(5.67/100000000)*(T**4)*e0",
  {
    'T': image.select('LST_Day_1km'),
    'e0':dataset.select("E0")

  });
  return(image.addBands(RL.rename("RL_up")));
};

var dataset2 = surfacetemp
                  .filterDate('2018-01-01', '2018-12-31')
                  .filterBounds(ROI)
                  .map(RL_up);

print("dataset2",dataset2);

var RL_up = dataset2.select("RL_up"); // To isolate just the albedo band
print("RL_up",RL_up); // Look at it

1 Answer 1

1

You have two different ImageCollections in you calculations so you will either 1) need to merge the two different ImageCollections where each image has the bands or 2) use the date information from one ImageCollection you are mapping over to look up the appropriate image from the other.

Here is a working example that uses option 2:

var surfacetemp = ee.ImageCollection("MODIS/006/MOD11A1");
var LAI = ee.ImageCollection("NOAA/CDR/AVHRR/LAI_FAPAR/V4");
var ROI = ee.Geometry.Rectangle([-95,27,-76,43]);

//outgoing long wave radiation 
var stfn = 5.67/100000000;

//Map.addLayer(Ts);
var e0 = function(image){
  var e01 = image.expression(
  "0.95 + 0.01*lai",
  {
    'lai': image.select('LAI'),

  });
  return(image.addBands(e01.rename("E0")));
};

var dataset = LAI.filterDate('2018-01-01', '2018-12-31')
                 .filterBounds(ROI)
                 .map(e0);

print("dataset",dataset);

var e0 = dataset.select("E0"); // To isolate just the albedo band
print("e0",e0); // Look at it

//Long wave radiation 
var RL_up = function(image){
  var t = image.date();
  var e0Img = ee.Image(dataset.filterDate(t,t.advance(1,'day')).first());
  e0Img = ee.Image(ee.Algorithms.If(e0Img,e0Img,ee.Image.random().rename('E0')));
  var RL = image.expression(
  "(5.67/100000000)*(T**4)*e0",
  {
    'T': image.select('LST_Day_1km'),
    'e0':e0Img.select("E0")

  });
  return(image.addBands(RL.rename("RL_up")));
};

var dataset2 = surfacetemp.filterDate('2018-01-01', '2018-12-31')
                  .filterBounds(ROI)
                  .map(RL_up);

print("dataset2",dataset2);

var RL_up = dataset2.select("RL_up"); // To isolate just the albedo band
print("RL_up",RL_up); // Look at it

Keep in mind that both approaches assume that the ImageCollections have images for each others dates. In this case they don't. So, a check was needed to see if an e0 image was available for that date and a random image is provided if no data is available.

I hope this helps!

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.