string attributes not correctly imported into spectral view
Comments (15)
-
reporter -
reporter - marked as blocker
-
Which data is used for this? Can you provide a unit test / snipped how you load the data?
-
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 ...
-
what is the type of QgsField ‘level_2’? (check the spectral library properties)
-
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
-
reporter Also note that “level_2_id” values are all zero after import into the SpectralView:
-
reporter And also note that “level_1_id” contains values of 5, which are not present in the original dataset:
-
- changed status to open
-
fixed wrong speclib attribute import, addresses
#463Signed-off-by: jakimowb benjamin.jakimow@geo.hu-berlin.de
→ <<cset 7897c7b5522a>>
-
@Andreas Janz please test if this fix works for you
-
reporter Looks good, thanks!
-
reporter BTW - did you change the “name” values? Or is this a bug?
-
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()
-
- changed status to closed
- Log in to comment
@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.