English | Deutsch

NDSI (Sentinel-2)

The Normalized Difference Snow Index shows snow and ice. Snow reflects a lot of green light and absorbs short-wave infrared light, so NDSI = (green - SWIR) / (green + SWIR) is high for snow and ice and low for most other surfaces. A value above about 0.4 is a common first guess for snow. The result is one number per pixel, between -1 and 1.

At a glance

Download function

download_normalized_difference_snow_index(), short download_ndsi

Plot function

plot_normalized_difference_snow_index(), short plot_ndsi

Source

Sentinel-2 Level-2A (collection SENTINEL2_L2A), bands B03 (green) and B11 (short-wave infrared)

Pixel size

10 m (B11 has 20 m detail)

Result

one band of floating-point numbers, no unit, -1 … 1

Clouds

scenes above max_cloud_cover (20 %) are not used; pixels are masked with scl_classes (default: vegetation, not vegetated, water and snow or ice)

Period

mean of all observations of temporal_extent

Example

There is no snow in Bremen in June, so this example looks at the Zugspitze in the Bavarian Alps in winter:

from cdec import download_ndsi, plot_ndsi

spatial_extent = {"west": 10.95, "south": 47.38, "east": 11.05, "north": 47.46}  # the Zugspitze
temporal_extent = ["2024-02-01", "2024-03-01"]  # February 2024, the end date is not included

path = download_ndsi("data/ndsi_zugspitze.tif", spatial_extent, temporal_extent, max_cloud_cover=50)
plot_ndsi(path)
NDSI of the Zugspitze in February 2024: snow-covered slopes in dark blue, snow-free ground in pale blue, white patches without data.

Zugspitze, February 2024. Dark blue: snow or ice. White: no data. Contains modified Copernicus Sentinel data 2024.

Things to know

  • Snow or cloud? Clouds and snow look alike. The scene classification can label snow as cloud and cloud as snow, and it removes everything it calls cloud. If a snowy area stays empty, download once with scl_classes=None and compare the result with the Scene classification (Sentinel-2).

  • Choose a short period. The mean of a long period mixes days with and without snow, and the result shows neither. For snow use a few days to a few weeks, and a higher max_cloud_cover in the mountains, where the weather changes quickly (Choose the period).

  • Snow is kept by default. The default scl_classes is (4, 5, 6, 11): the classes of NDWI (Sentinel-2) and the class snow or ice. NDVI and EVI drop snow (NDVI (Sentinel-2)).

  • Not every high value is snow. Thin clouds and some bright surfaces can also reach high values. Look at True-colour image (Sentinel-2) or False-colour SWIR image (Sentinel-2) of the same area to check.

  • The index is calculated from the mean reflectance of the period, not as the mean of the index of every date.

  • The plot uses white-blue colours and a fixed range of -1 to 1: the darker the blue, the more likely snow.

See also

False-colour SWIR image (Sentinel-2), Scene classification (Sentinel-2), Filter clouds, Choose the period

Download

cdec.download_normalized_difference_snow_index(file_path, spatial_extent, temporal_extent, max_cloud_cover=20, scl_classes=(4, 5, 6, 11), *, create_cog=True, overview_resampling='average')[source]

Short alias: download_ndsi

Download a Sentinel-2 NDSI (snow index) raster.

Green and short-wave infrared (B11) reflectance from Sentinel-2 Level-2A are masked using the Scene Classification Layer (SCL), then averaged over the requested period before calculating the Normalized Difference Snow Index:

NDSI = (green - SWIR) / (green + SWIR)

Snow is bright in green light and dark in short-wave infrared light, so the index is high over snow and ice. The output retains the 10 m reflectance grid; B11 and the SCL keep their native 20 m detail.

Parameters:
  • file_path (str | Path) – Destination path of the GeoTIFF file. Missing parent directories are created automatically.

  • spatial_extent (SpatialExtent) – Area to download: an openEO bounding-box dictionary such as {"west": 8.7, "south": 53.0, "east": 8.9, "north": 53.1} (degrees, WGS 84), a Shapely geometry, or the path to a GeoJSON file.

  • temporal_extent (TemporalExtent) – Start and end of the observation period, e.g. ["2024-06-01", "2024-07-01"]. The end date itself is not included, so this example covers all of June.

  • max_cloud_cover (int) – Maximum cloud cover of a whole scene in percent. Scenes that are cloudier are not used at all. This scene filter complements scl_classes, which removes single pixels.

  • scl_classes (Sequence[int] | None) – Scene Classification Layer (SCL) classes to keep, as a tuple of class IDs. The default SCL_LAND_WATER_AND_SNOW = (4, 5, 6, 11) keeps vegetation, non-vegetated land, water and snow or ice and drops clouds, cirrus, shadows, unclassified and defective pixels. Do not remove class 11: it is the snow that this index looks for. Use None to switch SCL masking off. Run cdec.show_scl_classes() to see what each class means. Pixels without any retained observation remain no data.

  • create_cog (bool) – If True, write a Cloud Optimized GeoTIFF.

  • overview_resampling (OverviewResampling) – Resampling method used to build COG overview levels.

Returns:

Absolute path of the GeoTIFF that was written. The file has one band of floating-point numbers (float32): the NDSI, a number without unit between -1 and 1 (snow and ice are above about 0.4). Pixels without data are NaN, which the file declares as its no-data value. The pixel size is 10 m, in the UTM zone of the area (EPSG:32632 for Bremen); B11 has only 20 m detail.

Return type:

Path

Plot

cdec.plot_normalized_difference_snow_index(file_path, *, ax=None, title=None, cmap='PuBu', vmin=-1.0, vmax=1.0, colorbar=True, show=None)[source]

Short alias: plot_ndsi

Draw the NDSI of download_normalized_difference_snow_index.

NDSI lies between -1 and 1: snow and ice are high (usually above 0.4), land and water are low. The colour map goes from white (low) to dark blue (high). The range is fixed to -1 … 1, so two images always have the same colours and can be compared.

Parameters:
  • file_path (str | Path) – The GeoTIFF written by download_ndsi.

  • ax (Axes | None) – A matplotlib Axes to draw into. None creates a new figure.

  • title (str | None) – Title of the plot. Default: “NDSI (Sentinel-2)”. Use "" for no title.

  • cmap (str) – Name of a matplotlib colour map.

  • vmin (float | None) – Values at the two ends of the colour map. None takes the smallest and largest value of the image instead.

  • vmax (float | None) – Values at the two ends of the colour map. None takes the smallest and largest value of the image instead.

  • colorbar (bool) – Draw a colour bar.

  • show (bool | None) – Call plt.show() at the end. The default (None) shows the figure only if this function created it.

Returns:

The axes with the plot, for further changes.

Return type:

matplotlib.axes.Axes

Raises:

ValueError – If the file does not have exactly one band.