Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

NDVI-based approach to study Landslide areas

Streamlining Cloud-Based Processing with EOPF and Xarray

Authors
Affiliations
Eurac Research
Eurac Research
ESA EOPF Zarr Logo

🚀 Launch in JupyterHub

Run this notebook interactively with all dependencies pre-installed

Preface

The original notebook used as a starting point for this work is a Copernicus Data Space Ecosystem example, available here.
The example has been adapted to use the data provided by the EOPF Zarr Samples project instead of the openEO API.

Introduction

Research indicates that NDVI can play a crucial role in identifying landslide zones. While an advanced workflow is possible, this notebook opts for a simple approach using the difference of NDVI and applying a threshold to the result to detect landslide occurred areas. Our analysis relies on the Sentinel-2 Level 2A data from the EOPF Sentinel Zarr Samples project.

Setup

Start importing the necessary libraries

/home/mclaus@eurac.edu/micromamba/envs/eopf-zarr/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html
  from .autonotebook import tqdm as notebook_tqdm

Dask Cluster

Create Local Dask Cluster to access and process the data in parallel.

/home/mclaus@eurac.edu/micromamba/envs/eopf-zarr/lib/python3.11/site-packages/distributed/node.py:187: UserWarning: Port 8787 is already in use.
Perhaps you already have a cluster running?
Hosting the HTTP server on port 41269 instead
  warnings.warn(
Loading...

Data Access

We now want to access a time series of Sentinel-2 data to compute the yearly NDVI index, remove cloudy pixels, and perform other processing steps.

List of available remote files

Here, we do the test for Ischia in Italy for the fall of 2022, where several landsides were registered.
The Sentinel-2 tiles covering the area are T33TVF and T33TUF and therefore we will query only the names containing the specific tile identifier.

In the cell below, we create a list of the matching Zarr files in the bucket.

We want to use only the data for the specific temporal range before and after the landslide.
Hence, we specify the time ranges and filter the products based on their acquisition date.

Finally, we test if all the dataset can be opened correctly.

Checking datasets:   0%|          | 0/34 [00:00<?, ?it/s]/home/mclaus@eurac.edu/micromamba/envs/eopf-zarr/lib/python3.11/site-packages/xarray_sentinel/esa_safe.py:7: UserWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html. The pkg_resources package is slated for removal as early as 2025-11-30. Refrain from using this package or pin to Setuptools<81.
  import pkg_resources
Checking datasets: 100%|██████████| 34/34 [00:01<00:00, 29.11it/s]
Found 34/34 valid datasets
Checking datasets: 100%|██████████| 4/4 [00:00<00:00, 40.25it/s]
Found 4/4 valid datasets

Data Cube Building

We can now create a Data Cube (which consist in an Xarray Dataset object) containing the full timeseries for the two selected temporal ranges, before and after the landslide.

We firstly convert the Area of Interest (AOI), given in EPSG:4326 coordinates, to the target Coordinate Reference System (CRS) of the selected Sentinel-2 data, which correspond to EPSG:32633.

Target CRS of the selected Sentinel-2 tiles: 32633

We now define an utility function which will extract the product date and assign it as a coordinate at loading time, which is necessary to stack the products along time.
Moreover, again at loading time, the data will also be cropped to the defined AOI over Ischia.

CPU times: user 492 ms, sys: 35.6 ms, total: 528 ms
Wall time: 1.68 s
Loading...
CPU times: user 59.7 ms, sys: 14.8 ms, total: 74.4 ms
Wall time: 211 ms
Loading...

The area of Ischia lies exactly in the overlapping part of two Sentinel-2 tiles. To harmonize the Data Cube along time, so that it contains only a slice per unique date, we will now use the groupy operator of Xarray. Notice the change in the number of labels along the time dimension after this operation.

Loading...

Compute Reflectance and NDVI

Before computing the average Normalized Difference Vegetation Index (NDVI) over time, we need to compute reflectance values.

To compute Bottom of Atmosphere Reflectance (BOA) values from the digital numbers (DNs) from original Sentinel SAFE data we would need to rescale the data following this formula:

L2A_BOA=(L2A_DN+BOA_ADD_OFFSET)/BOA_QUANTIFICATION_VALUEL2A\_BOA = (L2A\_DN + BOA\_ADD\_OFFSET) / BOA\_QUANTIFICATION\_VALUE

where BOA_ADD_OFFSET = -1000 and BOA_QUANTIFICATION_VALUE = 10000
ESA Reference: https://sentinels.copernicus.eu/web/sentinel/-/copernicus-sentinel-2-major-products-upgrade-upcoming

However, the scale and offset parameters in the Zarr metadata have been adapted so that Xarray can rescale the data automatically (setting mask_and_scale=True) and therefore the formula to get reflectance values is:
L2A_BOA=(L2A_ZARR_VALUE∗scale_factor)+add_offsetL2A\_BOA = (L2A\_ZARR\_VALUE * scale\_factor) + add\_offset

where add_offset = -0.1 and scale_factor = 0.0001
ESA EOPF reference: https://cpm.pages.eopf.copernicus.eu/eopf-cpm/main/PSFDjan2024.html#scaling

We finally compute the NDVI difference and save it as a geoTIFF.

/home/mclaus@eurac.edu/micromamba/envs/eopf-zarr/lib/python3.11/site-packages/dask/_task_spec.py:764: RuntimeWarning: divide by zero encountered in divide
  return self.func(*new_argspec)

Result Visualization

<Figure size 640x480 with 1 Axes>

A general observation drawn from the aforementioned result is that the red regions indicate potential landslide activity or vegetation loss.

The red region corresponds to an area where notably large landslides were recorded. However, some false positives can also be noticed in the northwest—an urban area, though not many landslides were reported in those regions. Hence, it is conceivable that there is a change in NDVI, but it might be due to many factors, such as cloud cover, harvesting, vegetation loss, etc. This shows that the difference in the NDVI approach is suitable for rapid mapping but can also contain a lot of misclassified pixels and needs further validation.