English | Deutsch
False-colour infrared image (Sentinel-2)¶
The classic picture for vegetation. The near-infrared band is shown as red, the red band as green and the green band as blue. Healthy plants reflect much near-infrared light, so vegetation looks red: the denser and healthier the plants, the brighter the red. Water absorbs near-infrared light and looks dark blue to black; built-up areas look grey to blue-grey, and bare soil looks pale brown to grey. Compare it with the true-colour image of the same area to learn the colours.
Download function |
|
|---|---|
Plot function |
|
Source |
Sentinel-2 Level-2A (collection |
Pixel size |
10 m |
Result |
by default an 8-bit colour picture (three bands, 0 … 255); with |
Clouds |
scenes above |
Period |
mean of all observations of |
Example¶
from cdec import download_infrared, plot_infrared
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_infrared("data/infrared_bremen.tif", spatial_extent, temporal_extent)
plot_infrared(path)
Bremen, June 2024. Red: vegetation, grey: built-up, black: water. White: no data. Contains modified Copernicus Sentinel data 2024.¶
Things to know¶
A fixed stretch. It is the stretch of the false-colour urban image: the reflectance 0 to 0.4 becomes 0 to 255, and the brightest values are compressed instead of clipped. No statistics of the image are used, so the same reflectance always gets the same colour and images of different dates or places can be compared by eye (Compare images).
Do not calculate with the picture. For differences and thresholds download with
enhance_contrast=False(Calculate with reflectance).Red is not always vegetation. Dry grass and bare fields reflect less near-infrared light than healthy plants and look pink or pale. For a number instead of a colour use the NDVI (Sentinel-2).
Pixels without data are masked in the file and transparent in the plot, as in the other pictures.
See also¶
True-colour image (Sentinel-2), False-colour urban image (Sentinel-2), False-colour SWIR image (Sentinel-2), Colours and values, Filter clouds
Download¶
- cdec.download_false_color_infrared(file_path, spatial_extent, temporal_extent, max_cloud_cover=20, scl_classes=(4, 5, 6), enhance_contrast=True, *, create_cog=True, overview_resampling='average')[source]¶
Short alias:
download_infraredDownload a Sentinel-2 false-colour infrared composite.
B08, B04 and B03 are displayed as red, green and blue, respectively (the classic colour-infrared picture). Observations are masked using SCL, averaged over the requested period, and then enhanced for display by stretching contrast and compressing highlights. The output grid is 10 m; SCL classification detail remains 20 m.
- Parameters:
file_path (str | Path) – Destination GeoTIFF path. Missing parent directories are created.
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_AND_WATER=(4, 5, 6)keeps vegetation, non-vegetated land and water and drops clouds, cirrus, shadows, snow/ice, unclassified and defective pixels. Add11to keep snow/ice, or useNoneto switch SCL masking off. Runcdec.show_scl_classes()to see what each class means. Pixels without any retained observation remain no data, also after contrast enhancement.enhance_contrast (bool) – If
True, create an 8-bit RGB image using a reflectance stretch of 0..0.4 with highlight compression. The stretch is fixed: it does not look at the values of the image, so the same reflectance always gets the same colour, and images of different dates or places can be compared by eye. IfFalse, retain the three bands as floating-point reflectance values (use this for calculations).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. By default (
enhance_contrast=True) it is a colour picture: three bands of 8-bit integers from 0 to 255, in the order red, green, blue (B08, B04, B03). Pixels without data are 0 in all bands; the file marks them with a mask, so GIS programs andrasteriotreat them as empty. Withenhance_contrast=Falsethe file holds the measurement instead: threefloat32bands of reflectance (0 = black, about 1 = white), with NaN where there is no data. The pixel size is 10 m, in the UTM zone of the area (EPSG:32632 for Bremen).- Return type:
Path
Plot¶
- cdec.plot_false_color_infrared(file_path, *, ax=None, title=None, show=None)[source]¶
Short alias:
plot_infraredDraw the picture of
download_false_color_infrared.Bands B08, B04 and B03 are shown as red, green and blue. In this false colour image vegetation looks red, water dark and built-up areas grey or blue-grey. A file downloaded with the default
enhance_contrast=Truealready holds 8-bit colours and is drawn as it is. A file downloaded withenhance_contrast=Falseholds reflectance; it gets the same contrast stretch (0 … 0.4) as the download would have applied, for the picture only. Pixels without data are transparent.- Parameters:
file_path (str | Path) – The GeoTIFF written by
download_infrared.ax (Axes | None) – A matplotlib
Axesto draw into.Nonecreates a new figure.title (str | None) – Title of the plot. Default: “False colour infrared (Sentinel-2)”. Use
""for no title.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 three bands, or if they are neither 8-bit nor floating-point.