gdal-raster-color-blend - Man Page

Name

gdal-raster-color-blend — Use a grayscale raster to replace the intensity of a RGB/RGBA dataset

Added in version 3.12.

Synopsis

Usage: gdal raster blend [OPTIONS] <COLOR-INPUT> <OVERLAY> <OUTPUT>

Blend/compose two raster datasets

Positional arguments:
  -i, --color-input, --input <COLOR-INPUT>             Input raster dataset [required] [not available in pipelines]
  --overlay <OVERLAY>                                  Overlay dataset [required]
  -o, --output <OUTPUT>                                Output raster dataset [required] [not available in pipelines]

Common Options:
  -h, --help                                           Display help message and exit
  --json-usage                                         Display usage as JSON document and exit
  --config <KEY>=<VALUE>                               Configuration option [may be repeated]
  -q, --quiet                                          Quiet mode (no progress bar or warning message) [not available in pipelines]

Options:
  -f, --of, --format, --output-format <OUTPUT-FORMAT>  Output format ("GDALG" allowed) [not available in pipelines]
  --co, --creation-option <KEY>=<VALUE>                Creation option [may be repeated] [not available in pipelines]
  --overwrite                                          Whether overwriting existing output dataset is allowed [not available in pipelines]
                                                       Mutually exclusive with --append
  --append                                             Append as a subdataset to existing output [not available in pipelines]
                                                       Mutually exclusive with --overwrite
  --operator <OPERATOR>                                Composition operator. OPERATOR=src-over|hsv-value|multiply|screen|overlay|hard-light|darken|lighten|color-dodge|color-burn (default: src-over)
  --opacity <OPACITY>                                  Opacity percentage to apply to the overlay dataset (0=fully transparent, 100=full use of overlay opacity) (default: 100)

Advanced Options:
  --if, --input-format <INPUT-FORMAT>                  Input formats [may be repeated] [not available in pipelines]
  --oo, --open-option <KEY>=<VALUE>                    Open options [may be repeated] [not available in pipelines]

Description

gdal raster blend allows the user to compose two raster datasets (of the same size) using a selected blending operation and an opacity setting.

This can be used for example to colorize a hillshade raster generated by gdal raster hillshade with an hypsometric rendering of a DEM generated by gdal raster color-map when using the hsv-value blending operator.

The more standard src-over blending operator, which does "alpha blending" is also available.

This subcommand is also available as a potential step of gdal raster pipeline

Gdalg Output (on-the-Fly / Streamed Dataset)

This program supports serializing the command line as a JSON file using the GDALG output format. The resulting file can then be opened as a raster dataset using the GDALG: GDAL Streamed Algorithm driver, and apply the specified pipeline in a on-the-fly / streamed way.

Program-Specific Options

--input <INPUT>

Name of the dataset into which to blend the overlay dataset. Required.

When using the hsv-value blending operator, this must be a three-band or four-band Byte raster.

--opacity <OPACITY>

Opacity to use when blending the overlay dataset, as a percentage between 0 and 100. 0 means that the overlay dataset is considered fully transparent. 100 means that the overlay dataset is blended at the maximum of its alpha channel. Defaults to 100.

--operator src-over|hsv-value|multiply|screen|overlay|hard-light|lighten|darken

Select the blending operator, which defines how the overlay dataset is blended into the input dataset. Defaults to src-over.

See Details of blending operations below for details about each operator.

--overlay <OVERLAY>

Name of the overlay dataset. Required

Standard Options

--append

Append input raster as a new subdataset to an existing output file. Only works with drivers that support adding subdatasets such as GTiff -- GeoTIFF File Format and GPKG -- GeoPackage raster This also creates the output dataset if it does not exist yet.

--co,  --creation-option <NAME>=<VALUE>

Many formats have one or more optional creation options that can be used to control particulars about the file created. For instance, the GeoTIFF driver supports creation options to control compression, and whether the file should be tiled.

May be repeated.

The creation options available vary by format driver, and some simple formats have no creation options at all. A list of options supported for a format can be listed with the --formats command line option but the documentation for the format is the definitive source of information on driver creation options. See Raster drivers format specific documentation for legal creation options for each format.

--if,  --input-format <format>

Format/driver name to be attempted to open the input file(s). It is generally not necessary to specify it, but it can be used to skip automatic driver detection, when it fails to select the appropriate driver. This option can be repeated several times to specify several candidate drivers. Note that it does not force those drivers to open the dataset. In particular, some drivers have requirements on file extensions.

May be repeated.

--oo,  --open-option <NAME>=<VALUE>

Dataset open option (format specific).

May be repeated.

-f,  --of,  --format,  --output-format <OUTPUT-FORMAT>

Which output raster format to use. Allowed values may be given by gdal --formats | grep raster | grep rw | sort

--overwrite

Allow program to overwrite existing target file or dataset. Otherwise, by default, gdal errors out if the target file or dataset already exists.

Details of Blending Operations

In the description of the blending operations, all values are normalized to [0,1] range and each channel value is premultiplied with the alpha channel value.

The following notations are used:

NOTE:

For efficiency, the implementation uses integer arithmetic on [0,255] range rather than floating point arithmetic on [0,1] range. This can explain minor differences with the formulas described below.

For all operator (unless otherwise specified) the alpha channel is computed as:

output_{A} = overlay_{A} + input_{A} - overlay_{A} * input_{A}

The following blending operators are available:

Overview of Raster Blend Operators

OperatorDescriptionExample
src-overStandard alpha blending (overlay composited over input)[image: src-over blending example] [image]
hsv-valueUses value from overlay and hue/saturation from input[image: hsv-value blending example] [image]
multiplyMultiplies input and overlay colors[image: multiply blending example] [image]
screenComplement then multiply colors[image: screen blending example] [image]
overlayCombines multiply and screen[image: overlay blending example] [image]
hard-lightMultiply or screen depending on overlay brightness[image: hard-light blending example] [image]
darkenKeeps the minimum of input and overlay components[image: darken blending example] [image]
lightenKeeps the maximum of input and overlay components[image: lighten blending example] [image]
color-dodgeBrightens input based on overlay[image: color-dodge blending example] [image]
color-burnDarkens input based on overlay[image: color-burn blending example] [image]

Return Status Code

The program returns status code 0 in case of success, and non-zero in case of error (non-blocking errors emitted as warnings are considered as a successful execution).

Examples

Example 1: Alpha blending of two datasets using 75% opacity for the overlay dataset.

$ gdal raster blend --opacity 75 source.tif overlay.tif out.tif

Example 2: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the hsv-value blending operator.

[image: Hillshade rendering of a DEM] [image] [image: Hypsometric rendering of a DEM] [image]

$ gdal raster blend --overlay=hillshade.tif --operator=hsv-value \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 3: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the multiply blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=multiply \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 4: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the screen blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=screen \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 5: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the overlay blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=overlay \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 6: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the hard-light blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=hard-light \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 7: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the darken blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=darken \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 8: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the lighten blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=lighten \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 9: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the color-dodge blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=color-dodge \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Example 10: Combine a hillshade and a hypsometric rendering of a DEM into a colorized hillshade using the color-burn blending operator.

$ gdal raster blend --overlay=hillshade.tif --operator=color-burn \
                    hypsometric.tif hypsometric_combined_with_hillshade.tif

[image: Colorized hillshade] [image]

Author

Even Rouault <even.rouault@spatialys.com>

Info

Jul 22, 2026 GDAL