Commit a8896b1b authored by Daniel Scheffler's avatar Daniel Scheffler

Fixed band names not properly read (fixed issue #26). Updated version info.

Signed-off-by: Daniel Scheffler's avatarDaniel Scheffler <danschef@gfz-potsdam.de>
parent 219191f7
Pipeline #4999 passed with stage
in 1 minute and 12 seconds
...@@ -775,7 +775,12 @@ class GeoArray(object): ...@@ -775,7 +775,12 @@ class GeoArray(object):
else: else:
self._metadata = GDAL_Metadata(filePath=self.filePath) 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 self._gdalDataset_meta_already_set = True
......
...@@ -20,5 +20,5 @@ ...@@ -20,5 +20,5 @@
# with this program. If not, see <http://www.gnu.org/licenses/>. # with this program. If not, see <http://www.gnu.org/licenses/>.
__version__ = '0.8.23' __version__ = '0.8.24'
__versionalias__ = '20191004.01' __versionalias__ = '20191010.01'
...@@ -63,6 +63,17 @@ class Test_GDAL_Metadata(TestCase): ...@@ -63,6 +63,17 @@ class Test_GDAL_Metadata(TestCase):
for bN in gA.bandnames.keys(): for bN in gA.bandnames.keys():
self.assertTrue(bN in content, msg="The band name '%s' is not in the written header." % bN) 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): def test_save_bandnames(self):
outPath = os.path.join(self.tmpOutdir.name, 'save_bandnames_from_numpy.bsq') outPath = os.path.join(self.tmpOutdir.name, 'save_bandnames_from_numpy.bsq')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment