diff --git a/geoarray/baseclasses.py b/geoarray/baseclasses.py index ba8f7c03e05f658d6124e1df0e31fa245bf77f4c..6d414beb0ef09c4d9059cf88b037ef1c140b033d 100644 --- a/geoarray/baseclasses.py +++ b/geoarray/baseclasses.py @@ -775,7 +775,12 @@ class GeoArray(object): else: self._metadata = GDAL_Metadata(filePath=self.filePath) - del ds + # copy over the band names + if 'band_names' in self.metadata.band_meta and self.metadata.band_meta['band_names']: + self.bandnames = self.metadata.band_meta['band_names'] + + # noinspection PyUnusedLocal + ds = None self._gdalDataset_meta_already_set = True diff --git a/geoarray/version.py b/geoarray/version.py index 375271504ff902ff6842d8ac8318ac7d22db5fa5..6c9ebdb56633730772bd50ca85c49a46e2f45db7 100644 --- a/geoarray/version.py +++ b/geoarray/version.py @@ -20,5 +20,5 @@ # with this program. If not, see . -__version__ = '0.8.23' -__versionalias__ = '20191004.01' +__version__ = '0.8.24' +__versionalias__ = '20191010.01' diff --git a/tests/test_metadata.py b/tests/test_metadata.py index 7c650095760a28c8924e99135a30de460dc76206..e44c90f0d5c591bab2eb17effded210241db1371 100644 --- a/tests/test_metadata.py +++ b/tests/test_metadata.py @@ -63,6 +63,17 @@ class Test_GDAL_Metadata(TestCase): for bN in gA.bandnames.keys(): self.assertTrue(bN in content, msg="The band name '%s' is not in the written header." % bN) + def test_read_bandnames(self): + outPath = os.path.join(self.tmpOutdir.name, 'read_bandnames_correctly.bsq') + bandnames = ['test1', 'band_2', 'layer 3'] + + gA = GeoArray(np.random.randint(1, 10, (5, 5, 3))) + gA.bandnames = bandnames + gA.save(outPath) + + gA = GeoArray(outPath) + self.assertEqual(list(gA.bandnames.keys()), bandnames) + def test_save_bandnames(self): outPath = os.path.join(self.tmpOutdir.name, 'save_bandnames_from_numpy.bsq')