2525
2626__revision__ = '$Format:%H$'
2727
28+ import os
29+
30+ from qgis .PyQt .QtGui import QIcon
31+
2832from qgis .analysis import QgsZonalStatistics
2933
3034from processing .core .GeoAlgorithm import GeoAlgorithm
3640from processing .core .outputs import OutputVector
3741from processing .tools import dataobjects
3842
43+ pluginPath = os .path .split (os .path .split (os .path .dirname (__file__ ))[0 ])[0 ]
44+
3945
4046class 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 )
0 commit comments