I’m trying to read envi file, modify and save back as envi file using spectral-python.
Here is the code gist:
<code>from spectral import *
numpy_ndarr = envi.open(header_file, spectral_file)
reflectance_array = numpy_ndarr.load()
reflectance_array_mod =reflectance_array /2 # example modification of spectral data
?? > numpy_ndarr_mod=numpy_ndarr.update(reflectance_array_mod) # This is the functionality I'm looking for
envi.save_image(new_header_file, numpy_ndarr_mod)
</code>
<code>from spectral import *
numpy_ndarr = envi.open(header_file, spectral_file)
reflectance_array = numpy_ndarr.load()
reflectance_array_mod =reflectance_array /2 # example modification of spectral data
?? > numpy_ndarr_mod=numpy_ndarr.update(reflectance_array_mod) # This is the functionality I'm looking for
envi.save_image(new_header_file, numpy_ndarr_mod)
</code>
from spectral import *
numpy_ndarr = envi.open(header_file, spectral_file)
reflectance_array = numpy_ndarr.load()
reflectance_array_mod =reflectance_array /2 # example modification of spectral data
?? > numpy_ndarr_mod=numpy_ndarr.update(reflectance_array_mod) # This is the functionality I'm looking for
envi.save_image(new_header_file, numpy_ndarr_mod)
I’ve looked in the library documentation for a function that could support these changes. the only thing that comes close to this is by using a protected attribute:
<code>numpy_ndarr._memmap = reflectance_array_mod
</code>
<code>numpy_ndarr._memmap = reflectance_array_mod
</code>
numpy_ndarr._memmap = reflectance_array_mod
But this led me to different issues down the path (the saved file is 4 times in size, even when zeroing out all values) so I hope there is a simpler and more elegant approach.
Does anyone know any method of another way to overcome this issue?