Skip to content
Permalink
Browse files

[processing] median calculation for zonal statistics

  • Loading branch information
alexbruy committed Apr 2, 2015
1 parent ed4fe88 commit ba73048dc2bb90ba56347eff2eb91db5a3b90cda
Showing with 5 additions and 6 deletions.
  1. +5 −6 python/plugins/processing/algs/qgis/ZonalStatistics.py
@@ -140,11 +140,10 @@ def processAlgorithm(self, progress):
columnPrefix + 'unique', 21, 6)
(idxRange, fields) = vector.findOrCreateField(layer, fields,
columnPrefix + 'range', 21, 6)
(idxVar, fields) = vector.findOrCreateField(layer, fields, columnPrefix
+ 'var', 21, 6)

# idxMedian, fields = ftools_utils.findOrCreateField(layer, fields,
# columnPrefix + "median", 21, 6)
(idxVar, fields) = vector.findOrCreateField(layer, fields,
columnPrefix + 'var', 21, 6)
(idxMedian, fields) = vector.findOrCreateField(layer, fields,
columnPrefix + 'median', 21, 6)

writer = self.getOutputFromName(self.OUTPUT_LAYER).getVectorWriter(
fields.toList(), layer.dataProvider().geometryType(), layer.crs())
@@ -225,7 +224,7 @@ def processAlgorithm(self, progress):
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(masked.median()))
attrs.insert(idxMedian, float(numpy.ma.median(masked)))

outFeat.setAttributes(attrs)
writer.addFeature(outFeat)

0 comments on commit ba73048

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