Example #1
0
    def test_list_bands_true(self):
        n = Nansat(self.test_file_gcps,
                   log_level=40,
                   mapper=self.default_mapper)
        lb = n.list_bands(True)

        self.assertEqual(lb, None)
Example #2
0
    def test_list_bands_false(self):
        n = Nansat(self.test_file_gcps,
                   log_level=40,
                   mapper=self.default_mapper)
        lb = n.list_bands(False)

        self.assertEqual(type(lb), str)
Example #3
0
    def test_list_bands_false(self):
        n = Nansat(self.test_file_gcps, logLevel=40)
        lb = n.list_bands(False)

        self.assertEqual(type(lb), str)
Example #4
0
    def test_list_bands_false(self):
        n = Nansat(self.test_file_gcps, logLevel=40)
        lb = n.list_bands(False)

        self.assertEqual(type(lb), str)
Example #5
0
n.set_metadata(key='GlobalKey', value='GlobalVal')
# get Global Metadata
print 'Global Metadata:', n.get_metadata(), '\n'

# set BandMetadata to the 1st band
n.set_metadata(key='BandKey', value='BandVal', bandID=1)
# get 1st Band Metadata
print '1st Band Metadata:', n.get_metadata(bandID=1), '\n'

# add a band from file (copy the 2nd band to the end (4th band)
n.add_band(fileName=n.fileName, bandID=2)
# add a band from numpy array (copy the 1st band to the end (5th band))
n.add_band(array=n[1], parameters={'name': 'Name1',
                                   'info':  'copy from the 1st band array'})
# print band list
n.list_bands()
# get GDAL raster band (2nd band)
band = n.get_GDALRasterBand(bandID=2)

# Get band data and do some operations
# -- Get data from 1st band as numpy array
a = n[1]
# -- Plot the array (pyplot image is save to a PNG file)
plt.imshow(a);plt.colorbar();plt.savefig(oFileName + '01_imshow.png');plt.close()
# -- Save as Matlab file
savemat(oFileName + '01.mat', {'band_1': a})

# Resize the data to 50%
n.resize(0.5)
# make simple indexed image from 1st band with default colormap
n.write_figure(oFileName + '02.png', clim='hist')