allow hubflow.core.ClassDefinition to use none-zero based classification scheme

Issue #508 resolved
Benjamin Jakimow created an issue

hubflow.core.ClassDefinition

assumes classes are labeled starting from zero (like assumed by GDAL), e.g. 1st class is labeled with raster value = 1, 2nd class value = 2 and so on.

It would be nice to allow for class definitions with explicite labels, similar to the QGIS Paletted raster renderer or the QPS widget to define a ClassificationScheme:

Comments (2)

  1. Andreas Janz

    You can now use the ids keyword to autofill the inbetween classes:

    classDefinitionNewStyle = ClassDefinition(classes=55,
        names=['11', '12', '13', '14', '15', '21', '22', '23', '24', '25', '31', '32', '33', '34', '35', '41', '42', '43',
               '44', '45', '51', '52', '53', '54', '55'],
        colors=[Color('#1d6318'), Color('#00ff88'), Color('#efb700'), Color('#e20003'), Color('#02f3ff'), Color('#e6df49'),
                Color('#35b646'), Color('#efb700'), Color('#da0003'), Color('#02f3ff'), Color('#d12ea6'), Color('#00ff88'),
                Color('#d0c264'), Color('#ed0003'), Color('#02f3ff'), Color('#79d2b2'), Color('#00ff88'), Color('#efb700'),
                Color('#ea747b'), Color('#02f3ff'), Color('#d23f3f'), Color('#00ff88'), Color('#efb700'), Color('#d70003'),
                Color('#57d4d2')],
        ids=[11, 12, 13, 14, 15, 21, 22, 23, 24, 25, 31, 32, 33, 34, 35, 41, 42, 43, 44, 45, 51, 52, 53, 54, 55]
    )
    

    results in:

    ClassDefinition(
        classes=55, 
        names=['Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', '11', '12', '13', '14', '15', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', '21', '22', '23', '24', '25', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', '31', '32', '33', '34', '35', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', '41', '42', '43', '44', '45', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', 'Unclassified', '51', '52', '53', '54', '55'], 
        colors=[Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#1d6318')), Color(Color('#00ff88')), Color(Color('#efb700')), Color(Color('#e20003')), Color(Color('#02f3ff')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#e6df49')), Color(Color('#35b646')), Color(Color('#efb700')), Color(Color('#da0003')), Color(Color('#02f3ff')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#d12ea6')), Color(Color('#00ff88')), Color(Color('#d0c264')), Color(Color('#ed0003')), Color(Color('#02f3ff')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#79d2b2')), Color(Color('#00ff88')), Color(Color('#efb700')), Color(Color('#ea747b')), Color(Color('#02f3ff')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#000000')), Color(Color('#d23f3f')), Color(Color('#00ff88')), Color(Color('#efb700')), Color(Color('#d70003')), Color(Color('#57d4d2'))]
    )
    

  2. Log in to comment