Springe direkt zu Inhalt

NBR - Sentinel-2

Let us now take a look at how to calculate the NBR using the Google Earth Engine.

As mentioned in the previous chapter, the NBR is the normalized difference of the infrared and the short wave infrared band, calculated as NDVI = (NIR-SWIR) / (NIR+SWIR).

Let us try to apply this to a Sentinel 2 Scene. For comparison reasons, we will have a look at the NBR for the same dataset of the same time and location as we did for the NDVI.

Preparing the data

The basic steps are identical, we mainly need to pay attention to using the correct bands and changing our nomenclature from NDVI to NBR.

// Compute Normalized Burn Ratio over S2-L2 product.
// NBR = (NIR - SWIR) / (NIR + SWIR), where
// NIR is B8, 835.1 nm
// SWIR is B12, 2202.4nm (S2A) / 2185.7nm (S2B) 	

//Step 1: Access your boundary-defining geometry
var extent_lebanon = ee.FeatureCollection("FAO/GAUL/2015/level0")
                  .filter(ee.Filter.eq('ADM0_NAME', 'Lebanon')); //filter for entry that equals the UN country name 'Lebanon'

//Step 2: Access the Sentinel-2 Level-2A data and filter it for all the the images of the year 2020 that lie within the geometries boundaries. Keep only the relevant bands and filter for cloud coverage.
var s2a = ee.ImageCollection('COPERNICUS/S2_SR')
                  .filterDate('2020-07-01', '2020-07-31')
                  .filter(ee.Filter.lt('CLOUDY_PIXEL_PERCENTAGE', 10));

//Print your ImageCollection to your console tab to inspect it
print(s2a, 'Image Collection Lebanon July 2020');

//Step 3: Create a single Image by reducing by Median and clip it to the extent of the geometry
var s2a_median = s2a.median()

//Print your Image to your console tab to inspect it
print(s2a_median, 'Median reduced Image Lebanon July 2020');

//Add your Image as a map layer
var visParams = {'min': 400,'max': [4000,3000,3000],   'bands':'B8,B4,B3'};
Map.addLayer(s2a_median, visParams, 'S2 Lebanon July 2020 Median');

Calculating the NBR

Just as for the NDVI, the GEE offers multiple ways to calculate the NBR from your image

Here, we will have a look at the three different approaches we already used to calculate the NDVI..

The first approach uses simple band operations integrated in the GEE to calculate band maths, the second approach uses the function .expression to write a mathematical formula and the third approach uses the function .normalizedDifference, which which calculates the Normalized Difference for two input variables.

Depending on your interests and research, you might find specific approaches superior to others.

//Step 4: Calculate the NBR manually: NBR = (B8 - B12) / (B8 + B12)
//This can be achieved using either simple band operations, .expression or .normalizedDifference
//Variant 1: Simple band operations
var nir = s2a_median.select('B8');
var swir = s2a_median.select('B12');
var nbr = nir.subtract(swir).divide(nir.add(swir)).rename('NBR');
print(nbr, 'NBR Lebanon July 2020 V1')

// Define special visualization parameters for the nbr and display the result.
var nbrParams = {min: -1, max: 1, palette: ['red', 'white', 'green']};
Map.addLayer(nbr, nbrParams, 'NBR Lebanon July 2020 V1');

//Variant 2: .expression
var nbr_2 = s2a_median.expression(
                      '(NIR-SWIR)/(NIR+SWIR)', {
                        'NIR' : s2a_median.select('B8'),
                        'SWIR' : s2a_median.select('B12')

print(nbr_2, 'NBR Lebanon July 2020 V2')

//Display the result
Map.addLayer(nbr_2, nbrParams , 'NBR Lebanon July 2020 V2');

//Variant 3: .normalizedDifference(NIR, SWIR)
//Find out how .normalizedDifference works by checking Docs -> ee.Image -> normalizedDifference
var nbr_3 = s2a_median.normalizedDifference(['B8', 'B12'])
print(nbr_3, 'NBR Lebanon July 2020 V3');

// Display the result
Map.addLayer(nbr_3, nbrParams, 'NBR Lebanon July 2020 V3')

Now that we have calculated and displayed the NBR in three different variants, we can use the Inspector to see that the pixel values are always identical!
The most convenient way to calculate the NBR is by using the normalizedDifference.