Learning goals

  • Convert digital number values (DN) to top-of-atmosphere reflectance (TOA)
  • Compare top-of-atmosphere reflectance to bottom-of-atmosphere reflectance (BOA)


What is radiance / what are DNs?

Today we will be dealing with physical units, conversion, and data quality. Let´s kick it off with a short recap. Towards the end of the last assignment, you produced a plot of measurements in the different bands of a Landsat image, similar to this one:

Our y-axis label was “DN”, or digital number. Now, what is that again? Optical Earth observing sensors, such as the ones on board the Landsat satellites, register radiance at the top of the atmosphere. Radiance is expressed in watt per steradian per square meter.

Storing data in radiance units is difficult and therefore sensors translate measured radiance into DNs. Therefore, the range of energy measured by the sensor is broken into distinct units (digital numbers, or DNs). Sensor-specific calibration determines the minimum and maximum amount of radiance that can be measured. DNs express the amount of radiance in relation to these sensor-specific calibration coefficients. The total number of possible DNs is what we refer to as the radiometric resolution of the sensor.

As an example, Landsat 4, 5, and 7 worked with a radiometric resolution of 8 bit. This allows for 2^8, or 255 distinct DNs values. Landsat 8 works with 12 bit radiometric resolution, which is artificially quantized to 16 bit. The 16 bit resolution can represent much more different grey shades, exactly 2^16, or 65,536 values. We will learn more on how we get these values in the next section, but for now let´s put this into code.

## Loading required package: sp
# Define the number of bits
bit <- 4

# How many grey tones can we represent given bit?
print(paste0(bit, ' bits produce ', 2^bit, ' grey tones.'))
## [1] "4 bits produce 16 grey tones."
# Create a new raster with one line and 2^bit columns,
# whereas cell values are filled with a vector of numbers from 1 to 2^bit
r <- raster(nrows = 1, ncols = 2^bit, vals = c(1:2^bit))

# Plot the raster and assign grey-scale values to the cells
image(r, col = grey.colors(2^bit, start = 0, end = 1), main = paste0(bit, ' bit raster'))

Let´s do the same with bit <- 16.

## [1] "16 bits produce 65536 grey tones."

DNs to TOA

As DNs are dependent on the sensor calibration, identical measurements yield differing DNs across sensors. DNs are physically not meaningful. Instead of DNs, often we are interested in reflectance. Reflectance expresses the fraction of reflected radiance relative to the total incoming energy (that is, from the sun), and is scaled between 0 and 1. Many applications require data converted to reflectance and/or corrected for the influence of the atmosphere. The following steps are necessary to convert DNs into (atmospherically corrected) bottom-of-atmosphere reflectance (BOA):

  • Sensor calibration (DN to radiance)
  • Conversion to top-of-atmosphere reflectance (radiance to TOA)
  • Atmospheric correction yielding bottom-of-atmosphere reflectance (TOA to BOA)

A conversion of DNs into radiance can be easily undertaken. By accounting for sun-sensor geometries and solar irradiance, we can easily infer top-of-atmosphere reflectance (TOA) from radiance. This facilitates, e.g., a comparison of measurements from different sensors.

Practically, this involves a linear scaling of the DN values which uses two band-specific rescaling factors. One is multiplicative, one is additive. Formulas are explained in the USGS guide for conversion to TOA Reflectance. With Landsat 8 Collection 1 data (this is not the case for all sensors!), we can use a single set of coefficients to convert DNs directly to TOA reflectance:

\(ρλ' = M_ρ * Q_{cal} + A_ρ\)


\(ρλ'\) = TOA planetary reflectance, without correction for solar angle.

\(M_ρ\) = Band-specific multiplicative rescaling factor from the metadata.

\(Q_{cal}\) = Quantized and calibrated standard product pixel values (DN).

\(A_ρ\) = Band-specific additive rescaling factor from the metadata.

In a next step, we can correct for solar angle during image acquisition.

\(ρλ = ρλ' / cos(θ_{SZ}) = ρλ' / sin(θ_{SE})\)


\(ρλ\) = TOA planetary reflectance corrected for solar angle.

\(θ_{SZ}\) = Local solar zenith angle, whereas \(θ_{SZ} = 90° - θ_{SE}\).

\(θ_{SE}\) = Local sun elevation angle.


Atmospheric correction is the final step towards comparable measurements of the Earth surface. By doing atmospheric correction, we (theoretically) eliminate the influence of the atmosphere. We therefore call the product “bottom-of-atmosphere reflectance” (BOA). Theoretically, the BOA measured by a space-borne sensor should be comparable to ground-based measurements.


During this assignment you will learn how to convert Landsat-8 Collection 1 DNs to TOA reflectance, and compare and characterize spectral appearance of different land cover types in TOA and BOA imagery. The data are available for download in two versions:

  • Reduced dataset: a spatial subset of the required bands, recommended.
  • Original dataset: the data as acquired via EarthExplorer, using this data will lead to longer processing times.

After unpacking, you find the following folders:

  • DN/LC08_L1TP_189025_20141105_20170417_01_T1/ - the directory containing the “L1TP” Landsat product (i.e. terrain-corrected (“orthorectified”) data in DNs), including the metadata file (MTL.txt) and the Quality Band (BQA.tif) which contains information on radiometric saturation, clouds, cloud shadows and more.

  • SR/LC081890252014110501T1-SC20170927102137/ – the directory containing BOA (atmospherically corrected) data.

1) DN to TOA conversion

Familiarize yourself with the L1TP data. Visualize individual bands, have a look at the Level-1 metadata file (LC08_L1TP_…_MTL.txt) and the information provided within.

Read the Landsat metadata file in R using read.delim() and extract the necessary information for the top-of-atmosphere conversion: - REFLECTANCE_MULT_BAND - REFLECTANCE_ADD_BAND - SUN_ELEVATION

Use the pattern matching function grep() to find the corresponding entries in the metadata file and store them as numeric vectors. Do this as follows:

# Define the folder that contains your data...
data.path <- 'course.dir/S02/data/DN'

# Read MTL file
mtl <- list.files(data.path, pattern='MTL.txt$', recursive=T, full.names=T)
mtl.txt <- read.delim(mtl, sep = '=', stringsAsFactors = F)

# Extract numeric values
REFLECTANCE_MULT_BAND <- as.numeric(mtl.txt[grep('REFLECTANCE_MULT_BAND',mtl.txt$GROUP),][2:7,2])
REFLECTANCE_ADD_BAND <- as.numeric(mtl.txt[grep('REFLECTANCE_ADD_BAND',mtl.txt$GROUP),][2:7,2])
SUN_ELEVATION <- as.numeric(mtl.txt[grep('SUN_ELEVATION',mtl.txt$GROUP),][2])

Convert the DN values to TOA following the “Conversion to TOA Reflectance” section in the USGS guide for conversion to TOA Reflectance. Important things to keep in mind:

  • We consider only the six reflective bands of the OLI sensor (3xVIS, nIR, 2xswIR).
  • You can apply the conversion to all bands in a stack simultaneously by applying the calculation on a stack object.
  • The Landsat data is provided as integer values. When applying the equation, the data will be cast to float. You will have to re-convert to integer at some point. Use a reflectance scaling factor of 10,000 during the conversion.
  • The sun elevation angle provided in the metadata file is reported in degrees. The sin() function expects that angles are provided in radians. For the conversion to work correctly, you need to convert SUN_ELEVATION into radians. Make use of this helper function:
# Helper-function to convert degrees to radians
deg2rad <- function(deg){ (deg * pi) / (180) }

Write the result of your TOA conversion to disk in the GTiff format. Make sure to use an integer data type to save disk space.

2) Compare TOA with BOA

Open the BOA and the TOA file in QGIS and visually assess the differences in the spectral signature between the SR and TOA files. Use the info tool in graph view to plot the spectral signatures of each of the following land cover types:

  • Forest
  • Open soil
  • Water

In your R script, add comments to answer the following questions:

  1. Briefly summarize the spectral appearance of the different land cover types.

  2. What are the most evident differences between TOA and SR reflectance spectra?

Copyright © 2020 Humboldt-Universität zu Berlin. Department of Geography.