- changed status to resolved
Classification Statistics fail
Issue #817
resolved
Calculation of classification statistics (runClassificationStatistics
) fails after the results are to be evaluated with “eval”.
How to reproduce:
- Open a classification raster in a map view
- Open raster layer context menu and run “Classification Statistics”
Traceback (most recent call last):
File "C:\Users\geo_beja\Repositories\enmap-box\enmapbox\gui\dataviews\dockmanager.py", line 1508, in <lambda>
action.triggered.connect(lambda: self.runClassificationStatistics(lyr))
File "C:\Users\geo_beja\Repositories\enmap-box\enmapbox\gui\dataviews\dockmanager.py", line 1630, in runClassificationStatistics
categories = eval(result[alg.P_OUTPUT_CATEGORIES])
File "<string>", line 1, in <module>
NameError: name 'Category' is not defined
Affected code: enmapbox/gui/dataviews/dockmanager.py
def runClassificationStatistics(self, layer):
from hubdsm.processing.classificationstatistics import ClassificationStatistics, ClassificationStatisticsPlot
alg = ClassificationStatistics()
io = {alg.P_CLASSIFICATION: layer}
result = Processing.runAlgorithm(alg, parameters=io, feedback=QgsProcessingFeedback())
categories = eval(result[alg.P_OUTPUT_CATEGORIES])
counts = eval(result[alg.P_OUTPUT_COUNTS])
widget = ClassificationStatisticsPlot(categories=categories, counts=counts, layer=layer,
parent=self.mDockTreeView)
widget.show()
Comments (2)
-
-
@Benjamin Jakimow how would I trigger a menu button programmatically? I would like to add some unittests for such GUI functionalities.
- Log in to comment
resolves
#817→ <<cset 5c5a15bb25cf>>