[Qgis-developer] Raster histogram in Python plugin

Benoit de Cabissole benoit at exigesa.com
Sun Oct 17 10:09:42 EDT 2010


 Hi all,

Is it possible to access the histogramVector attribute from the
QgsRasterBandStats Class in Python code from a plugin?

When the following code is run it issues the error:
AttributeError: 'QgsRasterBandStats' object has no attribute
'histogramVector'

self.theLayer.populateHistogram(1,grd.S.nClass)
myStats = self.theLayer.bandStatistics(1)
grd.S.Histo[0, 0] = myStats.histogramVector[0].y()

where 'self.theLayer' is a one band raster image and 'grd.S.nClass' = 40001

Python version: 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32
bit (Intel)]
QGIS version: 1.6.0-Trunk Trunk, 14378
>From OSGeo4W on WinXP.

Cheers,
Benoit



More information about the Qgis-developer mailing list