Wavelength in X-axis of Spectra instead of band nb.

Issue #229 closed
Agustin Lobo created an issue

I'm just trying EnMAP-Box and cannot find the way to set the X-axis of the spectral plots in Wavelength instead of band number. Is there a way? Thanks

Comments (17)

  1. Agustin Lobo reporter

    and how is the wl of each band specified? can the box use an envi hdr file? or just a txt file with 2 columns, band and wl?

  2. Agustin Lobo reporter

    I'm perfectly happy with envi's hdr, it is a "de facto" standard for hyperspectral metadata. I was actually worried that you might enforce a better (e.g. xml) but new (nobody using) format. I understand that, for enmap-box, this hdr does not require the companion file to be in "raw" format. I mean, I can have a geotif image "myimage.tif" and a companion "myimage.hdr" to describe the hyperspectral information.

  3. Agustin Lobo reporter

    Benjamin, In case we have e.g. a geotif multi or hyperspectral image (ima.tif), should we make a full hdr companion file (ima.hdr) to include wavelength description? In that case, what should we state in the "file type" field? Also, the fact that we have ima.tif and ima.hdr, is not going to confuse gdal that would try to open ima.tif as en envi file? Perhaps the best is if you could share an example of a non-envi image file and its hdr companion file.

  4. Benjamin Jakimow

    In this case we have the problem that a *.tif, which has it's internal way to store metadata, is combind with an ENVI header. QGIS and EnMAP-Box API automatically opens it with the GDAL TIFF Driver and those don't care about ENVI header file infos.

    Solution 1:

    Write your metadata as GDAL auxiliary metadata into a hires_berlin2.tif.aux.xml.

    <PAMDataset>
      <Metadata domain="ENVI">
        <MDI key="wavelength">{ 0.650, 0.550, 0.470000}</MDI>
        <MDI key="wavelength_units">Micrometers</MDI>
      </Metadata>
    </PAMDataset>
    

    The hires_berlin2.tif.aux.xml will be used to store other information as well, e.g. QGIS-based raster histogram statistics.

    Solution 2:

    Convert the hires_berlin2.tif into an ENVI-like hires_berlin2.bsq, which will let QGIS / EnMAP-Box / GDAL opened the binary file using the ENVI driver.

  5. Agustin Lobo reporter

    Hmmm... If I understand correctly, Solution 2 is not a solution: it is a change of format (I've tried just changing the extension from tif to bsq and I do not get to trick qgis: the file is still recognised as tif). As hyperspectral images use to be big, changing the format to have wavelength info in enmapbox is not a solution. We must avoid having to duplicate potentially huge files.

    Regarding Solution 1, it would be greatly appreciated a tool to write that info to the xml file from info provided by the user as a 2 columns txt file or from a built-in list of sensors (i.e. EnMap, ASTER, S2 etc). I find easy writing text files (even writing a simple function in R) but writing (and potentially damaging) xml files is not as easy.

    In any case, Solution 1 is not really as simple as having the required info in a companion hdr file, that is a simple text file to which everyone is used to and that does not interact with other qgis functionalities. I would favor

    Solution 3

    let enmapbox search the wavelength info in an optional companion file named i.e. *.hwl that would keep the fields wavelength units, band names, wavelength and fwhm following the same convention as hdr files.

  6. Benjamin Jakimow

    Plot and header look fine, but without REFL_FX17_DeceptionIsland24_2018-04-06_08-39-09.tif I can not test it in my EnMAP-Box.

    However, can you change the x-axis units via the plot context menu -> X Axis > Unit? Example screenshot

  7. Benjamin Jakimow

    The problem is that REFL_FX17_DeceptionIsland24_2018-04-06_08-39-09.tif.aux.xml defines 1024 wavelength values, but REFL_FX17_DeceptionIsland24_2018-04-06_08-39-09.tif consists of 224 bands only. This way the EnMAP-Box can not match the wavelength value to the existing raster bands.

    I'll add a warning to the source code and you just need to ensure that the number of float specified in

    <MDI key="wavelength">{935.61,939.06, ...}</MDI>
    

    is same as the number of bands.

  8. Agustin Lobo reporter

    I confirm it works with the correct nb. of wavelength values.
    So it was my fault. I probably Ctrl-pasted several times the vector of values. I apologize.

    Now that I have wavelength in the X-axis, I miss band numbers... Perhaps the little window in the plot could have x in wavelength and band nb. in (), ie:

    x: 850 (35)
    y: 0.345
    

    Thanks

  9. Log in to comment