merge a 3-band and 1-band image
Doodler
can use 1, 3, and 4-band input imagery. If the imagery is 3-band, it is assumed to be RGB and is, by default, augmented with 3 additional derivative bands.
But how do you make a 4-band image from a 3-band image and a 1-band image?
That additional 1-band might be that acquired with an additional sensor, but might more commonly be a DEM (Digital Elevation Model) corresponding to the scene.
I know of two ways. If you have gdal
binaries installed, first strip the image into its component bands using gdal_translate
Then merge them together using gdal_merge.py
The equivalent in python can be acheived without the gdal
bindings, using the libraries already in your doodler
conda environment
First, import libraries
Read RGB image
Read elevation and get just the first band (if this is 3-band)
If you had a 1-band elevation image, it would be this instead...
Merge bands - creates a numpy array with 4 channels
Write the image to file
You can use the following to read it back in
And verify with 'shape' - it should be 4 bands