English | Deutsch
EVI (Sentinel-2)¶
The Enhanced Vegetation Index is a second vegetation index. It uses the blue band to correct for the
atmosphere and does not level off as quickly as the NDVI over very dense vegetation. The formula is
EVI = 2.5 * (NIR - red) / (NIR + 6 * red - 7.5 * blue + 1).
Download function |
|
|---|---|
Plot function |
|
Source |
Sentinel-2 Level-2A (collection |
Pixel size |
10 m |
Result |
one band of floating-point numbers, no unit, typically 0 … 1 for vegetation |
Clouds |
scenes above |
Period |
mean of all observations of |
Example¶
from cdec import download_evi, plot_evi
spatial_extent = {"west": 8.721771, "south": 53.025027, "east": 8.904419, "north": 53.114965} # Bremen
temporal_extent = ["2024-06-01", "2024-07-01"] # June 2024, the end date is not included
path = download_evi("data/evi_bremen.tif", spatial_extent, temporal_extent)
plot_evi(path)
Bremen, June 2024. White: no data. Contains modified Copernicus Sentinel data 2024.¶
Things to know¶
Extreme values. The denominator of the formula can come close to zero, and then the result explodes. The example file ranges from -52 to 263, although its median is 0.39 and 99 % of its pixels lie between 0.01 and 0.83. Before you calculate statistics, clip the values or use percentiles instead of the maximum:
numpy.clip(evi, -1, 1).The plot uses a fixed range of -1 to 1. Pixels outside the range get the colour of the nearest end of the colour bar.
Like the NDVI, the index is calculated from the mean reflectance of the period, water is empty by default, and holes can be filled with a longer period (NDVI (Sentinel-2), Filter clouds).
See also¶
Download¶
- cdec.download_enhanced_vegetation_index(file_path, spatial_extent, temporal_extent, max_cloud_cover=20, scl_classes=(4, 5), *, create_cog=True, overview_resampling='average')[source]¶
Short alias:
download_eviDownload a Sentinel-2 Enhanced Vegetation Index (EVI) raster.
Blue, red and near-infrared reflectance from Sentinel-2 Level-2A are masked using the Scene Classification Layer (SCL), then averaged over the requested period before calculating EVI:
EVI = 2.5 * (NIR - red) / (NIR + 6 * red - 7.5 * blue + 1)The output retains the 10 m reflectance grid; SCL classification detail remains 20 m. As with
cdec.download_normalized_difference_vegetation_index(), the index is calculated from mean reflectance, rather than averaging indices from individual dates.- 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=(4, 5)keeps vegetation and non-vegetated land and drops water, clouds, cirrus, shadows, snow/ice, unclassified and defective pixels. UseSCL_LAND_AND_WATER=(4, 5, 6)to also keep water, orNoneto switch SCL masking off. Runcdec.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 EVI, a number without unit that is typically between 0 and 1 over vegetation. 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).- Return type:
Path
Plot¶
- cdec.plot_enhanced_vegetation_index(file_path, *, ax=None, title=None, cmap='RdYlGn', vmin=-1.0, vmax=1.0, colorbar=True, show=None)[source]¶
Short alias:
plot_eviDraw the EVI of
download_enhanced_vegetation_index.EVI is read like NDVI but reacts less to the atmosphere and does not saturate as early over dense vegetation. It uses the same colour map and the same fixed range (-1 … 1) as
plot_normalized_difference_vegetation_index(), so NDVI and EVI of the same area can be compared by eye.- Parameters:
file_path (str | Path) – The GeoTIFF written by
download_evi.ax (Axes | None) – A matplotlib
Axesto draw into.Nonecreates a new figure.title (str | None) – Title of the plot. Default: “EVI (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.
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.