@@ -57,6 +57,7 @@ class BasicStatisticsNumbers(GeoAlgorithm):
57
57
MAJORITY = 'MAJORITY'
58
58
FIRSTQUARTILE = 'FIRSTQUARTILE'
59
59
THIRDQUARTILE = 'THIRDQUARTILE'
60
+ NULLVALUES = 'NULLVALUES'
60
61
IQR = 'IQR'
61
62
62
63
def defineCharacteristics (self ):
@@ -86,6 +87,7 @@ def defineCharacteristics(self):
86
87
self .addOutput (OutputNumber (self .MAJORITY , self .tr ('Majority (most frequently occurring value)' )))
87
88
self .addOutput (OutputNumber (self .FIRSTQUARTILE , self .tr ('First quartile' )))
88
89
self .addOutput (OutputNumber (self .THIRDQUARTILE , self .tr ('Third quartile' )))
90
+ self .addOutput (OutputNumber (self .NULLVALUES , self .tr ('NULL (missed) values' )))
89
91
self .addOutput (OutputNumber (self .IQR , self .tr ('Interquartile Range (IQR)' )))
90
92
91
93
def processAlgorithm (self , progress ):
@@ -95,8 +97,6 @@ def processAlgorithm(self, progress):
95
97
96
98
outputFile = self .getOutputValue (self .OUTPUT_HTML_FILE )
97
99
98
- index = layer .fieldNameIndex (fieldName )
99
-
100
100
cvValue = 0
101
101
minValue = 0
102
102
maxValue = 0
@@ -108,6 +108,7 @@ def processAlgorithm(self, progress):
108
108
majority = 0
109
109
firstQuartile = 0
110
110
thirdQuartile = 0
111
+ nullValues = 0
111
112
iqr = 0
112
113
113
114
isFirst = True
@@ -117,8 +118,11 @@ def processAlgorithm(self, progress):
117
118
count = len (features )
118
119
total = 100.0 / float (count )
119
120
for current , ft in enumerate (features ):
120
- if ft .attributes ()[index ]:
121
- values .append (float (ft .attributes ()[index ]))
121
+ value = ft [fieldName ]
122
+ if value or value == 0 :
123
+ values .append (float (value ))
124
+ else :
125
+ nullValues += 1
122
126
123
127
progress .setPercentage (int (current * total ))
124
128
@@ -159,6 +163,7 @@ def processAlgorithm(self, progress):
159
163
data .append ('Majority (most frequently occurring value): ' + unicode (majority ))
160
164
data .append ('First quartile: ' + unicode (firstQuartile ))
161
165
data .append ('Third quartile: ' + unicode (thirdQuartile ))
166
+ data .append ('NULL (missed) values: ' + unicode (nullValues ))
162
167
data .append ('Interquartile Range (IQR): ' + unicode (iqr ))
163
168
164
169
self .createHTML (outputFile , data )
@@ -176,6 +181,7 @@ def processAlgorithm(self, progress):
176
181
self .setOutputValue (self .MAJORITY , majority )
177
182
self .setOutputValue (self .FIRSTQUARTILE , firstQuartile )
178
183
self .setOutputValue (self .THIRDQUARTILE , thirdQuartile )
184
+ self .setOutputValue (self .NULLVALUES , nullValues )
179
185
self .setOutputValue (self .IQR , iqr )
180
186
181
187
def createHTML (self , outputFile , algData ):
0 commit comments