English | Deutsch
Soil water index¶
How wet is the soil? The Soil Water Index (SWI) of the Copernicus Land Monitoring Service describes the soil moisture in percent: 0 is dry, 100 is saturated. It is calculated from radar data and available for Europe on a 1 km grid, every day.
Download function |
|
|---|---|
Plot function |
|
Source |
Copernicus Land Monitoring Service (collection |
Pixel size |
1 km |
Result |
one band of floating-point numbers in percent, 0 … 100 |
Clouds |
not affected (it is a modelled product) |
Period |
mean of all days of |
Example¶
from cdec import download_swi, plot_swi
spatial_extent = {"west": 8.721771, "south": 53.025027, "east": 8.904419, "north": 53.114965} # Bremen
temporal_extent = ["2025-08-01", "2025-09-01"] # August 2025, the end date is not included
path = download_swi("data/swi_bremen.tif", spatial_extent, temporal_extent, depth=20)
plot_swi(path)
Bremen, August 2025, depth=20. White: no data. Generated using European Union’s Copernicus Land Monitoring Service information.¶
Things to know¶
Check the dates first. The collection holds version 2 of the 1 km SWI and starts on 2025-07-12 at 12:00 UTC; version 1 covers 2015 up to 2025-07-12. An earlier period (such as June 2024) may find no data in this collection. The Copernicus Data Space also labels its CLMS collections as experimental.
The depth. The
depthargument is the characteristic time length T of the index in days: 2, 5, 10, 15, 20, 40, 60 or 100. A small T follows recent rain and describes the topsoil; a large T is slow and describes deeper layers. The default is 2.Empty blocks. In the example about a third of the pixels have no value.
The plot uses white-to-blue colours and a fixed range of 0 to 100, so the same colour always means the same moisture.
The file uses longitude and latitude (EPSG:4326).
See also¶
Download¶
- cdec.download_soil_water_index(file_path, spatial_extent, temporal_extent, depth=2, *, create_cog=True, overview_resampling='average')[source]¶
Short alias:
download_swiDownload the mean Soil Water Index (SWI) of a period.
The function loads one SWI band from the
CLMS_SWI_EUROPE_1KM_DAILY_V2openEO collection (Europe, 1 km, daily) and calculates the temporal mean for the requested period. The SWI describes soil moisture in percent (0 = dry, 100 = saturated) according to the CLMS product description.Check the dates before you use this function: the collection holds version 2 of the 1 km SWI and starts on 2025-07-12 at 12:00 UTC, while version 1 covers 2015 up to 2025-07-12. Earlier periods may therefore find no data in this collection. CDSE also labels its openEO CLMS collections as experimental.
- 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.
["2025-08-01", "2025-09-01"]. The end date itself is not included, so this example covers all of August.depth (Literal[2, 5, 10, 15, 20, 40, 60, 100]) – Characteristic time length T of the SWI in days. One of 2, 5, 10, 15, 20, 40, 60 or 100. Small values describe the topsoil, large values the deeper and slower soil layers.
create_cog (bool) – If
True, write a Cloud Optimized GeoTIFF. IfFalse, keep a regular GeoTIFF.overview_resampling (OverviewResampling) – Resampling method used to build COG overview levels.
"average"is a suitable default for continuous data.
- Returns:
Absolute path of the GeoTIFF that was written. The file has one band of floating-point numbers (
float32): the soil water index in percent, from 0 (dry) to 100 (saturated). Pixels without data are NaN, which the file declares as its no-data value. The coordinate system is geographic (EPSG:4326, degrees); the pixel size is 0.0089 degrees, about 1 km.- Return type:
Path
- Raises:
ValueError – If
depthis not one of the available values. This is checked before connecting to the backend.
Plot¶
- cdec.plot_soil_water_index(file_path, *, ax=None, title=None, cmap='Blues', vmin=0.0, vmax=100.0, colorbar=True, show=None)[source]¶
Short alias:
plot_swiDraw the soil moisture of
download_soil_water_index.The soil water index is given in percent: 0 is dry, 100 is saturated. The colour map goes from white (dry) to dark blue (wet). The range is fixed to 0 … 100, so images of different days can be compared.
- Parameters:
file_path (str | Path) – The GeoTIFF written by
download_swi.ax (Axes | None) – A matplotlib
Axesto draw into.Nonecreates a new figure.title (str | None) – Title of the plot. Default: “Soil water index”. Use
""for no title.cmap (str) – Name of a matplotlib colour map.
vmin (float | None) – Values at the two ends of the colour map.
Nonetakes the smallest and largest value of the image instead.vmax (float | None) – Values at the two ends of the colour map.
Nonetakes 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.