Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] median calculation for zonal statistics
  • Loading branch information
alexbruy committed Apr 2, 2015
1 parent ed4fe88 commit ba73048
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions python/plugins/processing/algs/qgis/ZonalStatistics.py
Expand Up @@ -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())
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit ba73048

Please sign in to comment.