[gdal-dev] gdalbuildvrt and band descriptions

Matt.Wilkie at yukon.ca Matt.Wilkie at yukon.ca
Fri Mar 26 16:40:17 PDT 2021


Hi Folks,

`gdal_translate -b 1 infile.tif outfile.vrt` will copy the band 1 description to the output file.

`gdalbuild.vrt` on the other hand leaves the band descriptions behind. Is there a way to have vrt carry the description across also?

The project behind the question is to keep only the 4 bands of interest from 6 bands spread across two files (Red, Green, Blue and Near infrared) and merge them into a single output file, and keep all their metadata. VRT is a good intermediary except for it drops the band descriptions. (And some other metadata too, but I'm less concerned about that.)

Split each band into a single vrt:

gdal_translate -b 1 rgb.tif b-red.vrt
gdal_translate -b 2 rgb.tif b-grn.vrt
gdal_translate -b 3 rgb.tif b-blu.vrt
gdal_translate -b 1 infrared.tif b-nir.vrt

Stack the 4 bands we want back together:

gdalbuildvrt -separate rgb-nir.vrt b-red.vrt b-grn.vrt b-blu.vrt b-nir.vrt


Currently I'm hand editing the last stage vrt to put the description back in, but it's a pain and error prone. Is there a better way?

In the end I want arcgis desktop users to see something like the image on the left (plus the additional NIR band) instead of the right, which is what happens when there's no description.

[Machine generated alternative text: WorldView-3 Blue (0.450 - 0.510) um  WorldView-3 Green (0.510 - 0.380) um  WorldView-3 Red (0.630 - 0.690) um]

[Machine generated alternative text: @ Band_l  Band_2  Band_3]


Cheers,
Matt Wilkie
Geomatics Analyst
Environment | Technology, Innovation and Mapping
T 867-667-8133 | Yukon.ca<http://yukon.ca/>
Hours: 08:30-16:30, Tue-Wed: Office, Thu-Fri: Remote.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210326/33b96f3f/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5832 bytes
Desc: image001.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210326/33b96f3f/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image002.png
Type: image/png
Size: 3692 bytes
Desc: image002.png
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210326/33b96f3f/attachment-0003.png>


More information about the gdal-dev mailing list