EnMAP-Box / enmap-box

EnMAP-Box source code repository. See https://enmap-box.readthedocs.io for documentation
GNU General Public License v3.0
34 stars 16 forks source link

Spectral resampling: Missing wavelength definition for spectral raster layer: raster #933

Closed Maesiu closed 11 hours ago

Maesiu commented 3 days ago

Hi, The spectral resampling tools (to any sensor) seem not to work properly.

Error: Missing wavelength definition for spectral raster layer: raster

The error appears for all .bsq files I use as input. The wavelength definition should be correct in the .hdr file:

ENVI description = { E:/20220530_AVIRIS_NG_Irlbach/Irlbach/400_2500nm_Cut/ang20210530t101445_rfl_wlCut.bsq} samples = 663 lines = 2837 bands = 419 header offset = 0 file type = ENVI Standard data type = 3 interleave = bsq byte order = 0 map info = {UTM, 1, 1, 332499.642028, 5419368.76286, 5.3, 5.3, 33, North,WGS-84} coordinate system string = {PROJCS["unnamed",GEOGCS["GCS_WGS_1984",DATUM["D_WGS_1984",SPHEROID["WGS_1984",6378137.0,298.257223563]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",15.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]} band names = { Band 1, Band 2, ... Band 418, Band 419} data ignore value = -9999 fwhm = {5.590000000000001, ..., 6.0200000000000005, 6.0200000000000005, 6.0200000000000005} wavelength = {402.11182099999996, ..., 2485.7218209999996, 2490.731821, 2495.741821} wavelength units = Nanometer

janzandr commented 3 days ago

Hi @Maesiu, please share your ENVI file.

Maesiu commented 3 days ago

ang20210530t101445_rfl_wlCut_minisubset_TO_NoOverlapMEAN.zip

I would like to resample ang20210530t101445... into 20240501_102037_01_NoOverlapMEAN...

Maesiu commented 3 days ago

ok, further errors to be reported. The first error disappeared although I do not know why?

If I use an .hdr-file as FWHM and wavelength source:

Traceback (most recent call last):
File "C:\Users\m.wocher\AppData\Roaming\Python\Python312\site-packages\typeguard\__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/m.wocher/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\spectralresamplingbywavelengthandfwhmalgorithm.py", line 75, in processAlgorithm
f = Utils().wavelengthUnitsConversionFactor(srcUnits, 'nanometers')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\m.wocher\AppData\Roaming\Python\Python312\site-packages\typeguard\__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/m.wocher/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\utils.py", line 751, in wavelengthUnitsConversionFactor
toNanometers = {
^
KeyError: None

If I use the .bsq file as FWHM and wavelength source:

Traceback (most recent call last):
File "C:\Users\m.wocher\AppData\Roaming\Python\Python312\site-packages\typeguard\__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/m.wocher/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\spectralresamplingbywavelengthandfwhmalgorithm.py", line 120, in processAlgorithm
text.append(f"responses[{round(wavelength, 1)}] = {round(fwhm, 1)}")
^^^^^^^^^^^^^^^^^^^^
TypeError: type NoneType doesn't define __round__ method

If I use a .csv-table with wavelength and fwhm columns:

Traceback (most recent call last):
File "C:\Users\m.wocher\AppData\Roaming\Python\Python312\site-packages\typeguard\__init__.py", line 1033, in wrapper
retval = func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "C:\Users/m.wocher/AppData/Roaming/QGIS/QGIS3\profiles\default/python/plugins\enmapboxplugin\enmapboxprocessing\algorithm\spectralresamplingbywavelengthandfwhmalgorithm.py", line 84, in processAlgorithm
if array[0, 0] != 'wavelength':
~~~~~^^^^^^
IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed

Thank you for looking into it! Greetings, Matthias

janzandr commented 11 hours ago

Hi @Maesiu, your ENVI header has a typo. Nanometer (without the letter "s" at the end) is incorrect.

See: https://www.nv5geospatialsoftware.com/docs/ENVIHeaderFiles.html image

janzandr commented 11 hours ago

Nevertheless, I will support the spelling without a the "s" in the future.