TransWikia.com

Masked result from image expression

Geographic Information Systems Asked by Alaa on June 1, 2021

I am writing a code to calculate the Land Surface Temperature (LST), and one of the variables needed for this are the atmospheric factors w1, w2, w3.

First, I added them as a property to each image in an image collection, and used the image.expression to claulate the LST. This method didn’t work as the image.expression doesn’t accept an attribute in a mathematical operation with an image and gave me an error, as it requires an image. It only worked when I replaced the variables with constant float values.

Second, I tried adding these parameters as bands to the images, but when I map the LST function over the image collection I find using the inspector that the parameters (W1, W2 and W3) and LST maps are masked.

I hope someone could find where the problem is, otherwise I will have to run the code image by image and add the values manually, which is not ideal.

//adding WV value as a property and parameters as a property and image band
function addWV(WV, image){
  var W1 = ee.Number.expression('(0.0109 * (W**3)) + (0.0079 * (W**2)) + (0.0991 * W) + 1.0090', {
    'W': WV
  });
  var W2 = ee.Number.expression('(-0.0620 * W**3) + (-0.4671 * W**2) + (-1.2105 * W) + 0.1176',{
    'W': WV
  });
  var W3 = ee.Number.expression('(-0.0533 * W**3) + (0.4013 * W**2) + (0.8585 * W) - 0.0451',{
    'W': WV
  }) ;
  image = ee.Image(image).set('WV', WV);
  image = image.set('W1', W1);
  image = image.set('W2', W2);
  image = image.set('W3', W3);
  var img_W1 = ee.Image.constant(W1).rename('W1');
  var img_W2 = ee.Image.constant(W2).rename('W2');
  var img_W3 = ee.Image.constant(W3).rename('W3');
  
  image = image.addBands(img_W1);
  image = image.addBands(img_W2);
  image = image.addBands(img_W3);
  return image
}

// Land Surface Temperature 
var img = ee.Image(list.get(5));
  var H = img.select('H');
  var E = img.select('EM');
  var W1 = img.select('W1');  //I have also tried .get('W1') as an image property
  var W2 = img.select('W2');
  var W3 = img.select('W3');
  var L = img.select('B10');
  var G = img.select('G');
   var lst = L.expression(
    '(H * (1/E * ((L * W1) + W2) + W3) + G)', {
      'H': H,
      'E': E,
      'W1': W1,// if I set here a specific value instead of W1 it would work like 1.0045
      'W2': W2,
      'W3': W3,
      'L': L,
      'G': G
    }).rename('LST');

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP