How can I create a multispectral image file (in band sequential (BSQ) format), from several 1-band images, using GDAL libraries? I work with C++ language. Thanks for your attention.
|
From C++ you can create your output file using GDALDriver::Create() to imperatively create your multi-band output file. Then open each of your input files in turn read the band of image data with GDALRasterBand::RasterIO(), and then write it to the appropriate output band in the output file. This assumes each band isn't too large to hold in RAM. If you want to copy over a band in chunks you could do it yourself, our you might consider using GDALRasterBandCopyWholeRaster() which will do it in reasonable sized chunks with an optional progress monitor. The gdal_translate program actually accomplishes copies in a much more complicated way where it forms a VRTDataset referencing the source image and then uses CreateCopy() from that, but this complication is mostly just of value if you want to write to a format that does not support GDALDriver::Create() so that you need to use GDALDriver::CreateCopy() instead. For instance many compressed formats. But if you just want to create a raw BSQ format like ESRI BIL that is not required. |
|||
|
|