You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to save the imported 2D numpy array "Band1 using envi.save_saveimage with interleave ='bsq', I get the following error:
File "...\Python27\lib\site-packages\spectral\io\envi.py", line 537, in _prepared_data_and_metadata
data = data.transpose(interleave_transpose(src_interleave, interleave))
ValueError: axes don't match array
The problem is that read_band() returns a 2D, not a 3D numpy array, which cannot be transposed with the argument (2,0,1), which is returned by spectral.io.spyfile.interleave_transpose('bip','bsq').
In my case I try to do this:
data = np_array_of_shape_10_10.transpose(2,0,1)
ValueError: axes don't match array
Solution:
The 2D numpy array returned by Obj.read_band(0) has to be converted into a 3D array like this:
Band1 = Obj.read_band(0)
Band1 = Band1[ : , : , numpy.newaxis]
Afterwards it can be saved by envi.save_image @tboggs
Would it be possible modify the save_image function to be compatible with 2D numpy arrays?
The text was updated successfully, but these errors were encountered:
Version 0.16.1:
I imported a single band like this:
When I try to save the imported 2D numpy array "Band1 using envi.save_saveimage with interleave ='bsq', I get the following error:
The problem is that read_band() returns a 2D, not a 3D numpy array, which cannot be transposed with the argument (2,0,1), which is returned by spectral.io.spyfile.interleave_transpose('bip','bsq').
In my case I try to do this:
Solution:
The 2D numpy array returned by Obj.read_band(0) has to be converted into a 3D array like this:
Band1 = Obj.read_band(0)
Band1 = Band1[ : , : , numpy.newaxis]
Afterwards it can be saved by envi.save_image
@tboggs
Would it be possible modify the save_image function to be compatible with 2D numpy arrays?
The text was updated successfully, but these errors were encountered: