Skip to content
Permalink
Browse files

[processing] add icon for zonal statistics tool

  • Loading branch information
alexbruy committed Oct 20, 2016
1 parent 7bd4315 commit 8f7183b2a4480ab0013057982be18081e5c36c76
@@ -25,6 +25,10 @@

__revision__ = '$Format:%H$'

import os

from qgis.PyQt.QtGui import QIcon

from qgis.analysis import QgsZonalStatistics

from processing.core.GeoAlgorithm import GeoAlgorithm
@@ -36,6 +40,8 @@
from processing.core.outputs import OutputVector
from processing.tools import dataobjects

pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]


class ZonalStatisticsQgis(GeoAlgorithm):

@@ -46,6 +52,9 @@ class ZonalStatisticsQgis(GeoAlgorithm):
STATISTICS = 'STATS'
OUTPUT_LAYER = 'OUTPUT_LAYER'

def getIcon(self):
return QIcon(os.path.join(pluginPath, 'images', 'zonalstats.png'))

def defineCharacteristics(self):
self.STATS = {self.tr('Count'): QgsZonalStatistics.Count,
self.tr('Sum'): QgsZonalStatistics.Count,
@@ -67,7 +76,8 @@ def defineCharacteristics(self):
self.addParameter(ParameterRaster(self.INPUT_RASTER,
self.tr('Raster layer')))
self.addParameter(ParameterNumber(self.RASTER_BAND,
self.tr('Raster band'), 1, 999, 1))
self.tr('Raster band'),
1, 999, 1))
self.addParameter(ParameterVector(self.INPUT_VECTOR,
self.tr('Vector layer containing zones'),
[dataobjects.TYPE_VECTOR_POLYGON]))
@@ -96,7 +106,11 @@ def processAlgorithm(self, progress):
for i in st:
selectedStats |= self.STATS[keys[i]]

zs = QgsZonalStatistics(vectorLayer, rasterPath, columnPrefix, bandNumber, selectedStats)
zs = QgsZonalStatistics(vectorLayer,
rasterPath,
columnPrefix,
bandNumber,
selectedStats)
zs.calculateStatistics(None)

self.setOutputValue(self.OUTPUT_LAYER, vectorPath)
Binary file not shown.

0 comments on commit 8f7183b

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