string attributes not correctly imported into spectral view

Issue #463 closed
Andreas Janz created an issue

Comments (15)

  1. Andreas Janz reporter

    @Benjamin Jakimow now that I’m adopting the SpeclibVectorLayer format for training machine learners, this bug is a real blocker for me. Please fix it ASAP.

  2. Andreas Janz reporter

    Sure

    from qgis._core import QgsVectorLayer, QgsRasterLayer
    
    from enmapbox.externals.qps.speclib.core import SpectralLibrary
    from enmapboxtestdata import enmap, landcover_points
    
    lyrV = QgsVectorLayer(landcover_points)
    lyrR = QgsRasterLayer(enmap)
    slib = SpectralLibrary.readFromVector(lyrV, lyrR, copy_attributes=True)
    
    for profile in slib:
        print(profile.attribute('level_2'))
    

    Prints numbers instead of names:

    5
    1
    1
    1
    4
    5
    1
    1
    ...
    

  3. Andreas Janz reporter

    The type is String, which is correct, but the values are wrong!

    >>>print(slib.fields().field('level_2').typeName())
    String
    

    Values should be the class clear names

  4. Andreas Janz reporter

    Also note that “level_2_id” values are all zero after import into the SpectralView:

  5. Andreas Janz reporter

    And also note that “level_1_id” contains values of 5, which are not present in the original dataset:

  6. Benjamin Jakimow

    Neither nor. its a new naming as <fid>_<px number> to give spectral profiles a unique name.

    I’ll change it to <name>_<px number>, in case the the vector layer contains a text field called “NaMe”.lower()

  7. Log in to comment