Springe direkt zu Inhalt

NDVI - Difference Image

Difference Images can be really useful for monitoring sceneries, as they allow us to evaluate the condition of the environment before and after an event.
To create a Difference Image, simply subtract a post-event Image from a pre-event Image. The resulting Image will provide information on how the pixel values changed during the event, allowing further analysis. A NDVI-Difference Image, for example, allows us to analyse which pixels are more, less or equally vegetated before or after an event.

Calculating the Difference Image

Let us have a look at the difference image of two individual points in time: the median NDVI of 2014 and the median NDVI of 2020.

var pre_event = ls8_ndvi
              .filterDate('2014-01-01', '2014-12-31')
Map.addLayer(pre_event.clip(extent_aoi), ndviParams, 'Pre-Event', false);

var post_event = ls8_ndvi
              .filterDate('2020-01-01', '2020-12-31')
Map.addLayer(post_event.clip(extent_aoi), ndviParams, 'Post-Event', false);

//Adding the pre- and post-event layers to the map might make our project take a bit longer to compute and render, however there is also one decisive advantage; we can later use the maps to extract NDVI-values via the Inspector!  
//If this bothers you, simply add false to the command line or untick the layer in the map panel.

var ndvi_diff = pre_event.subtract(post_event).clip(extent_aoi);
print(ndvi_diff, 'NDVI difference Image 2014 / 2020)');

Visualizing the Difference Image

As the Difference Image stores different information than the NDVI, we will want to define new visualization parameters for it.


Negative values (minimum = -2) have higher post-event NDVI-values than pre-event NDVI-values, so we will display them in green as they are now more vegetated.

Example: pre-event - post-event = difference image; 0.2 - 0.6 = -0.4


~0 values are more or less unchanged, so we will display them in white


Positive values (maximum = 2) have lower post-event NDVI-values than pre-event NDVI-values, so we will display them in brown as they are now less vegetated.

Example: pre-event - post-event = difference image; 0.6 - 0.2 = 0.4


We will still only look at the range of -1 to 1, as most of the values lie within that range. If we would look at the full range of -2 to 2, it would be really hard to extract information just by looking at the map.

var dndviParams = {min: -1, max: 1, palette: ['DarkGreen', 'green', 'LimeGreen', 'white', 'burlywood', 'brown', 'maroon']};
Map.addLayer(ndvi_diff.clip(extent_aoi), dndviParams, 'NDVI diff Image 2014 / 2020', false);

Use the Inspector to look at NDVI-values for specific pixels of the pre-event, post-event and Difference Image-NDVI!