Skip to content
Permalink
Browse files

Keep correct order for zonal stats options, set some stats by default

  • Loading branch information
nyalldawson committed Jul 6, 2017
1 parent 4eca20f commit 4fa2bc025c6c03587eef38145530f4ead48cb02a
Showing with 17 additions and 16 deletions.
  1. +17 −16 python/plugins/processing/algs/qgis/ZonalStatistics.py
@@ -26,6 +26,7 @@
__revision__ = '$Format:%H$'

import os
from collections import OrderedDict

from qgis.PyQt.QtGui import QIcon

@@ -61,20 +62,19 @@ def group(self):

def __init__(self):
super().__init__()
self.STATS = {self.tr('Count'): QgsZonalStatistics.Count,
self.tr('Sum'): QgsZonalStatistics.Sum,
self.tr('Mean'): QgsZonalStatistics.Mean,
self.tr('Median'): QgsZonalStatistics.Median,
self.tr('Std. dev.'): QgsZonalStatistics.StDev,
self.tr('Min'): QgsZonalStatistics.Min,
self.tr('Max'): QgsZonalStatistics.Max,
self.tr('Range'): QgsZonalStatistics.Range,
self.tr('Minority'): QgsZonalStatistics.Minority,
self.tr('Majority (mode)'): QgsZonalStatistics.Majority,
self.tr('Variety'): QgsZonalStatistics.Variety,
self.tr('Variance'): QgsZonalStatistics.Variance,
self.tr('All'): QgsZonalStatistics.All
}
self.STATS = OrderedDict([(self.tr('Count'), QgsZonalStatistics.Count),
(self.tr('Sum'), QgsZonalStatistics.Sum),
(self.tr('Mean'), QgsZonalStatistics.Mean),
(self.tr('Median'), QgsZonalStatistics.Median),
(self.tr('Std. dev.'), QgsZonalStatistics.StDev),
(self.tr('Min'), QgsZonalStatistics.Min),
(self.tr('Max'), QgsZonalStatistics.Max),
(self.tr('Range'), QgsZonalStatistics.Range),
(self.tr('Minority'), QgsZonalStatistics.Minority),
(self.tr('Majority (mode)'), QgsZonalStatistics.Majority),
(self.tr('Variety'), QgsZonalStatistics.Variety),
(self.tr('Variance'), QgsZonalStatistics.Variance),
(self.tr('All'), QgsZonalStatistics.All)])

self.addParameter(QgsProcessingParameterRasterLayer(self.INPUT_RASTER,
self.tr('Raster layer')))
@@ -86,10 +86,11 @@ def __init__(self):
[QgsProcessingParameterDefinition.TypeVectorPolygon]))
self.addParameter(QgsProcessingParameterString(self.COLUMN_PREFIX,
self.tr('Output column prefix'), '_'))
keys = list(self.STATS.keys())
self.addParameter(QgsProcessingParameterEnum(self.STATISTICS,
self.tr('Statistics to calculate'),
list(self.STATS.keys()),
allowMultiple=True))
keys,
allowMultiple=True, defaultValue=[0,1,2]))
self.addOutput(QgsProcessingOutputVectorLayer(self.INPUT_VECTOR,
self.tr('Zonal statistics'),
QgsProcessingParameterDefinition.TypeVectorPolygon))

0 comments on commit 4fa2bc0

Please sign in to comment.
You can’t perform that action at this time.