I am using GDAL to merge a series of overlapping rasters using Pixel Functions to combine the color bands. As a proof-of-concept, my approach has been to create a VRT, and then to modify it in a text editor:
- Add the
VRTDerivedRasterBand
subclass to theVRTRasterBand
tags - Add
<PixelFunctionCode>
(and related) tags to implement the functions. - Cut&paste the
<ComplexSource>
tags between bands. Specifically, the new Green (2) band required input from both Red (1) and Green(2) bands. The order here matters, but as long as it is consistent then my custom function can be modified accordingly.
This proof-of-concept had three input rasters, but I wish to work with a variable number.
I also need to automate the entire sequence with one script or program. I'm currently working with Python, but could switch to C/C++.
Can I use the GDAL API to perform these manipulations of the VRT? Can I change the sub-class?
Looks like SetMetadataItem() might be usable to add new XML tags(?) but how can I change the sub-class of an existing VRTRasterBand? Or to remove and replace with a new one?
I can't create a new blank VRT and build it from the ground up, because I do not know the grid size and transform for the final image.
Or is the best approach to directly modify the VRT's XML using something like XSLT?