Skip to content
Browse files
[processing] don't write NaN's to attribute table (fix #14639)
(cherry picked from commit 77d95b0)
  • Loading branch information
alexbruy committed Apr 26, 2016
1 parent 1eed72c commit 6b02745e085bcf83ce819e5e94ee2bb2f501c553
Showing with 16 additions and 8 deletions.
  1. +16 −8 python/plugins/processing/algs/qgis/
@@ -227,16 +227,24 @@ def processAlgorithm(self, progress):

attrs = f.attributes()
attrs.insert(idxMin, float(masked.min()))
attrs.insert(idxMax, float(masked.max()))
attrs.insert(idxSum, float(masked.sum()))
v = float(masked.min())
attrs.insert(idxMin, None if numpy.isnan(v) else v)
v = float(masked.max())
attrs.insert(idxMax, None if numpy.isnan(v) else v)
v = float(masked.sum())
attrs.insert(idxSum, None if numpy.isnan(v) else v)
attrs.insert(idxCount, int(masked.count()))
attrs.insert(idxMean, float(masked.mean()))
attrs.insert(idxStd, float(masked.std()))
v = float(masked.mean())
attrs.insert(idxMean, None if numpy.isnan(v) else v)
v = float(masked.std())
attrs.insert(idxStd, None if numpy.isnan(v) else v)
attrs.insert(idxUnique, numpy.unique(masked.compressed()).size)
attrs.insert(idxRange, float(masked.max()) - float(masked.min()))
attrs.insert(idxVar, float(masked.var()))
attrs.insert(idxMedian, float(
v = float(masked.max()) - float(masked.min())
attrs.insert(idxRange, None if numpy.isnan(v) else v)
v = float(masked.var())
attrs.insert(idxVar, None if numpy.isnan(v) else v)
v = float(
attrs.insert(idxMedian, None if numpy.isnan(v) else v)
if hasSciPy:
attrs.insert(idxMode, float(mode(masked, axis=None)[0][0]))

0 comments on commit 6b02745

Please sign in to comment.