Friday, 18 August 2017

raster - Adding band to existing GeoTiff using GDAL?


This seems like it should be straightforward but I can't for the life of me figure it out.


Given an existing GeoTiff containing a single band, how can you add another band to that GeoTiff? Is the only way to do this to use GDALCreate() to create a new output file with an additional band and then copy the existing band from the original file to the new file? That's the only solution I've come up with so far but it just seems like there should be a simple way to add a band to the existing dataset.



Answer




The solution, if the driver suuports it, is to call GDALOpen() with GA_Update access then use GDALAddBand or GDALDataset::AddBand. However, the geotiff driver doesn't support AddBand.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...