2

I want to produce a set of VRTs (GDAL's internal virtual rasters) that comprise a re-arrangement of bands of a number of individual GeoTIFF files. Say I have my initial set of GeTIFF files, all having 4 bands:

file_01: band_01...band_04
file_02: band_01...band_04
file_03: band_01...band_04
file_04: band_01...band_04
file_05: band_01...band_04

And what I want to have is

vrt_01: file_01:band_01 file_02:band_01 file_03:band_01 file_04:band_01 file_05:band_01
vrt_02: file_01:band_02 file_02:band_02 file_03:band_02 file_04:band_02 file_05:band_02
vrt_03: file_01:band_03 file_03:band_03 file_03:band_04 file_04:band_03 file_05:band_03
vrt_04: file_01:band_04 file_04:band_04 file_03:band_04 file_04:band_04 file_05:band_04

My initial thoughts were:

  1. Use gdalbuildvrt, creating an "file of files", but I don't think you can specify a particular band, just filenames
  2. Use gdal_translate to create VRTs of the individual bands for each file, then proceed as in (1) above, but that looks like far too much effort.

I'd like to avoid creating the XML file myself because I find that that is quite error prone and requires quite a bit of debugging (they can all have different extents, etc etc etc)

2
  • 1
    I post this as a comment because I could only come up with answers you do not want :( I believe that the best people have come up with is to use gdaltranslate to do exactly as you mentioned or to alter the xml by creating it yourself or after making one (adding your file 4 times and going through and editing the bands you don't want). I have some links in case you decide to go with these : mail-archive.com/[email protected]/msg13303.html (brief discussion and same answer as here); gdal.org/gdal_vrttut.html (tutorial on how to edit the vrts); Hope this helps
    – s_a
    Oct 1, 2012 at 13:40
  • Thanks, in the end I use method (2) and then (1). I was just wondering whether there was a more direct way of doing this.
    – Jose
    Oct 1, 2012 at 15:19

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.