Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer 1

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.