I am writing numpy arrays out as ENVI images using gdal in python. Until today, I always accessed the header the hard way by reading in all lines, changing some information and writing it out again. This is not only coding intensive, but also yields multiple error sources.
A better solution would be by using SetMetadata. I tried:
myArray = np.full(shape=(4,3), fill_value=10) driver = gdal.GetDriverByName('ENVI') destination = driver.Create("test.bsq", ncols, nrows, 1, gdal.GDT_Float32) destination.GetRasterBand(1).WriteArray(myArray) destination.SetMetadataItem('band names', 'band hello world', 'ENVI')
but in the output file, the band is still called "band 1". Is my information overwritten by the built-in function for header creation?
Or maybe I have to set the name for each band individually like
b = destination.GetRasterBand(1) b.SetBandName("band hello world") b.WriteArray(myArray)
But "SetBandName" does not exist and I cannot find how else it is supposed to be called.
How do I supply band names for ENVI-images then?