26
26
__revision__ = '$Format:%H$'
27
27
28
28
import os
29
+ from collections import OrderedDict
29
30
30
31
from qgis .PyQt .QtGui import QIcon
31
32
@@ -61,20 +62,19 @@ def group(self):
61
62
62
63
def __init__ (self ):
63
64
super ().__init__ ()
64
- self .STATS = {self .tr ('Count' ): QgsZonalStatistics .Count ,
65
- self .tr ('Sum' ): QgsZonalStatistics .Sum ,
66
- self .tr ('Mean' ): QgsZonalStatistics .Mean ,
67
- self .tr ('Median' ): QgsZonalStatistics .Median ,
68
- self .tr ('Std. dev.' ): QgsZonalStatistics .StDev ,
69
- self .tr ('Min' ): QgsZonalStatistics .Min ,
70
- self .tr ('Max' ): QgsZonalStatistics .Max ,
71
- self .tr ('Range' ): QgsZonalStatistics .Range ,
72
- self .tr ('Minority' ): QgsZonalStatistics .Minority ,
73
- self .tr ('Majority (mode)' ): QgsZonalStatistics .Majority ,
74
- self .tr ('Variety' ): QgsZonalStatistics .Variety ,
75
- self .tr ('Variance' ): QgsZonalStatistics .Variance ,
76
- self .tr ('All' ): QgsZonalStatistics .All
77
- }
65
+ self .STATS = OrderedDict ([(self .tr ('Count' ), QgsZonalStatistics .Count ),
66
+ (self .tr ('Sum' ), QgsZonalStatistics .Sum ),
67
+ (self .tr ('Mean' ), QgsZonalStatistics .Mean ),
68
+ (self .tr ('Median' ), QgsZonalStatistics .Median ),
69
+ (self .tr ('Std. dev.' ), QgsZonalStatistics .StDev ),
70
+ (self .tr ('Min' ), QgsZonalStatistics .Min ),
71
+ (self .tr ('Max' ), QgsZonalStatistics .Max ),
72
+ (self .tr ('Range' ), QgsZonalStatistics .Range ),
73
+ (self .tr ('Minority' ), QgsZonalStatistics .Minority ),
74
+ (self .tr ('Majority (mode)' ), QgsZonalStatistics .Majority ),
75
+ (self .tr ('Variety' ), QgsZonalStatistics .Variety ),
76
+ (self .tr ('Variance' ), QgsZonalStatistics .Variance ),
77
+ (self .tr ('All' ), QgsZonalStatistics .All )])
78
78
79
79
self .addParameter (QgsProcessingParameterRasterLayer (self .INPUT_RASTER ,
80
80
self .tr ('Raster layer' )))
@@ -86,10 +86,11 @@ def __init__(self):
86
86
[QgsProcessingParameterDefinition .TypeVectorPolygon ]))
87
87
self .addParameter (QgsProcessingParameterString (self .COLUMN_PREFIX ,
88
88
self .tr ('Output column prefix' ), '_' ))
89
+ keys = list (self .STATS .keys ())
89
90
self .addParameter (QgsProcessingParameterEnum (self .STATISTICS ,
90
91
self .tr ('Statistics to calculate' ),
91
- list ( self . STATS . keys ()) ,
92
- allowMultiple = True ))
92
+ keys ,
93
+ allowMultiple = True , defaultValue = [ 0 , 1 , 2 ] ))
93
94
self .addOutput (QgsProcessingOutputVectorLayer (self .INPUT_VECTOR ,
94
95
self .tr ('Zonal statistics' ),
95
96
QgsProcessingParameterDefinition .TypeVectorPolygon ))
0 commit comments