Search code examples
javascriptimagegisgoogle-earth-enginemathematical-expressions

Constructing a Mathematical Equation for Image Bands in Google Earth Engine


I am struggling with an equation, getting some syntax error in it, The equation is following: formula: (K2 / ln ((K1/TOA_band10)+1)) - 273.15

I am trying to do operation on image bands, but not being able to construct the right code. I have used this instead:

var BT = band_10.expression((1329.2405*1.0/((799.0284*1.0/TOA_B10)+1).log10())-273.15)

But it did not work.

A general hint about constructing an equation in earth engine - javascript.


Solution

  • You're in the right direction. You have to include the map property of expression(). It defines the variables you can use inside your expression. Then with some minor tweaks to the actual expression, it works fine:

    var BT = ee.Image().expression(
      '(K2 / log((K1 / TOA_band10) + 1)) - 273.15',
      {
        K1: 799.02841,
        K2: 1329.24051,
        TOA_band10: someImage
      }
    )
    

    https://code.earthengine.google.com/e5cf09e87ddf51ec27a00b8ed4695ce4