xrspatial.multispectral.true_color(r, g, b, nodata=1, c=10.0, th=0.125, name='true_color')[source]

Create true color composite from a combination of red, green and blue bands satellite images.

A sigmoid function will be used to improve the contrast of output image. The function is defined as normalized_pixel = 1 / (1 + np.exp(c * (th - normalized_pixel))) where c and th are contrast and brightness controlling parameters.

  • r (xarray.DataArray) – 2D array of red band data.

  • g (xarray.DataArray) – 2D array of green band data.

  • b (xarray.DataArray) – 2D array of blue band data.

  • nodata (int, float numeric value) – Nodata value of input DataArrays.

  • c (float, default=10) – Contrast and brighness controlling parameter for output image.

  • th (float, default=0.125) – Contrast and brighness controlling parameter for output image.

  • name (str, default='true_color') – Name of output DataArray.


true_color_agg – 3D array true color image with dims of [y, x, band]. All output attributes are copied from red band image.

Return type

xarray.DataArray of the same type as inputs


import matplotlib.pyplot as plt
from xrspatial.multispectral import true_color
from xrspatial.datasets import get_data

# Open Example Data
data = get_data('sentinel-2')

red = data['Red']
green = data['Green']
blue = data['Blue']

# Generate ARVI Aggregate Array
true_color_img = true_color(r=red, g=green, b=blue)

(png, hires.png, pdf)