Skip to content

Commit 8f7183b

Browse files
committed
[processing] add icon for zonal statistics tool
1 parent 7bd4315 commit 8f7183b

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

python/plugins/processing/algs/qgis/ZonalStatisticsQgis.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@
2525

2626
__revision__ = '$Format:%H$'
2727

28+
import os
29+
30+
from qgis.PyQt.QtGui import QIcon
31+
2832
from qgis.analysis import QgsZonalStatistics
2933

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

43+
pluginPath = os.path.split(os.path.split(os.path.dirname(__file__))[0])[0]
44+
3945

4046
class ZonalStatisticsQgis(GeoAlgorithm):
4147

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

55+
def getIcon(self):
56+
return QIcon(os.path.join(pluginPath, 'images', 'zonalstats.png'))
57+
4958
def defineCharacteristics(self):
5059
self.STATS = {self.tr('Count'): QgsZonalStatistics.Count,
5160
self.tr('Sum'): QgsZonalStatistics.Count,
@@ -67,7 +76,8 @@ def defineCharacteristics(self):
6776
self.addParameter(ParameterRaster(self.INPUT_RASTER,
6877
self.tr('Raster layer')))
6978
self.addParameter(ParameterNumber(self.RASTER_BAND,
70-
self.tr('Raster band'), 1, 999, 1))
79+
self.tr('Raster band'),
80+
1, 999, 1))
7181
self.addParameter(ParameterVector(self.INPUT_VECTOR,
7282
self.tr('Vector layer containing zones'),
7383
[dataobjects.TYPE_VECTOR_POLYGON]))
@@ -96,7 +106,11 @@ def processAlgorithm(self, progress):
96106
for i in st:
97107
selectedStats |= self.STATS[keys[i]]
98108

99-
zs = QgsZonalStatistics(vectorLayer, rasterPath, columnPrefix, bandNumber, selectedStats)
109+
zs = QgsZonalStatistics(vectorLayer,
110+
rasterPath,
111+
columnPrefix,
112+
bandNumber,
113+
selectedStats)
100114
zs.calculateStatistics(None)
101115

102116
self.setOutputValue(self.OUTPUT_LAYER, vectorPath)
733 Bytes
Loading

0 commit comments

Comments
 (0)