1

I want to use two NBR images(NBR1 and NBR2) for the differenced Normalized Burn Ratio (dNBR). But I can't identify the error of dNBR output.

Code snippet:

var NBR1 = landsat8_1.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_1.select("B7"),    //SWIR2
          NIR: landsat8_1.select("B5"),    // NIR
          BLUE: landsat8_1.select("B2")    // BLUE
        });

var NBR2 = landsat8_2.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_1.select("B7"),    //SWIR2
          NIR: landsat8_1.select("B5"),    // NIR
          BLUE: landsat8_1.select("B2")    // BLUE
        });

var dNBR = NBR1.subtract(NBR2);

Full code: code.earthengine.google.com/14aaf46d74850fec158b3485c6fe702c

3
  • 1
    Hi, please elaborate your question. What's the problem? Do you see an error message? Add the link to your code for debugging as well
    – aldo_tapia
    Commented Dec 17, 2021 at 13:01
  • I want to use two NBR images for the differenced Normalized Burn Ratio (dNBR) But I don't know how to do the code code.earthengine.google.com/14aaf46d74850fec158b3485c6fe702c
    – willy1104
    Commented Dec 20, 2021 at 2:53
  • @willy1104 the question is closed yet, but I modified it for you. Check the code added and you will be able to identify the problem, which is just in front of your eyes.
    – aldo_tapia
    Commented Dec 20, 2021 at 13:02

1 Answer 1

1

Well, always check your code and debug it. Look your code:

var NBR1 = landsat8_1.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_1.select("B7"),    //SWIR2
          NIR: landsat8_1.select("B5"),    // NIR
          BLUE: landsat8_1.select("B2")    // BLUE
        });

var NBR2 = landsat8_2.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_1.select("B7"),    //SWIR2
          NIR: landsat8_1.select("B5"),    // NIR
          BLUE: landsat8_1.select("B2")    // BLUE
        });

You are applying the same expression with the same image and storing it in two different objects. That's why the output of dNBR is empty. Modify it and you will have the desired output:

var NBR1 = landsat8_1.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_1.select("B7"),    //SWIR2
          NIR: landsat8_1.select("B5"),    // NIR
          BLUE: landsat8_1.select("B2")    // BLUE
        });

var NBR2 = landsat8_2.expression(
        "(NIR - SWIR2) / (NIR + SWIR2)",
        {
          SWIR2: landsat8_2.select("B7"),    //SWIR2 of 2nd image
          NIR: landsat8_2.select("B5"),    // NIR of 2nd image
          BLUE: landsat8_2.select("B2")    // BLUE of 2nd image
        });

var dNBR = NBR1.subtract(NBR2);

Please, always check your code twice. This is a common mistake

1
  • Thank you very much for your feedback! This is a great help and reminder to a beginner First of all, I should do a good and complete study
    – willy1104
    Commented Dec 22, 2021 at 2:48

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.