Skip to content

Commit

Permalink
[processing] add icon for zonal statistics tool
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Oct 20, 2016
1 parent 7bd4315 commit 8f7183b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions python/plugins/processing/algs/qgis/ZonalStatisticsQgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):

Expand All @@ -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,
Expand All @@ -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]))
Expand Down Expand Up @@ -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 added python/plugins/processing/images/zonalstats.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 8f7183b

Please sign in to comment.