Spectral library as raster: Inconsistencies between speclib + processing algos

Issue #588 closed
Fabian Thiel created an issue

If a speclib is converted to a raster via the spectra library menu, the resulting raster is different compared to the output of the Import Data → Import Library algorithm.

The wavelength metadata is also stored differently. Algos expect them to be in the ENVI domain (?), whereas the output of the spectral library stores them somewhere else. Consistency is needed here, as e.g. Spectral Resampling algos will not work with the raster output of the spectral library as currently implemented.

Also, rasters are created with different dimensions: Import Library Algo uses 1 x 1:n (along y), the library export uses 1:n x 1 (along x)

Traceback (most recent call last):
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\enmapboxgeoalgorithms\provider.py", line 155, in processAlgorithm
    result = self.processAlgorithm_()
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\enmapboxgeoalgorithms\algorithms.py", line 1881, in processAlgorithm_
    sensor.resampleRaster(filename=filename, raster=raster, resampleAlg=resampleAlg, progressBar=self._progressBar)
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\hubflow\core.py", line 2130, in resampleRaster
    sourceSensor = raster.sensorDefinition()
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\hubflow\core.py", line 1490, in sensorDefinition
    return SensorDefinition._fromFWHM(centers=self.metadataWavelength(), fwhms=self.metadataFWHM())
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\hubflow\core.py", line 1442, in metadataWavelength
    wavelength = self.dataset().metadataItem(key='wavelength', domain='ENVI', dtype=float, required=True)
  File "C:\Users\thielf54\Documents\Repositories\enmap-box\hubdc\core.py", line 1418, in metadataItem
    raise errors.MissingMetadataItemError(key=key, domain=domain)
hubdc.hubdcerrors.MissingMetadataItemError: MissingNoDataValueError: required metadata item 'wavelength' in domain 'ENVI' not found

Error when using Speclib exported raster as input for Spectral Resampling to Sensor

Comments (7)

  1. Benjamin Jakimow

    I prefere to export speclibs as single line (instead of single column), as this better fits to common screen proportions = width < height.
    However, I think it is more important that such “artificial” exports still have a valid CRS + Projection that other algos can work with.
    E.g. some GDAL functions will fail if image dimensions exceed that of the used CRS (e.g. pixel latitudes > 90°).

  2. Andreas Janz

    @Benjamin Jakimow wavelength and fwhm info needs to go to the ENVI domain. Storage as row or column doesn’t matter.

  3. Benjamin Jakimow

    I think it was closed already before.
    Nevertheless it should be still (and will be) possible to Export Spectral Profiles as raster images and vice versa.
    I just need to update the SpectralLibraryIO for that

  4. Log in to comment