[Qgis-developer] Raster histogram in Python plugin

Tim Sutton lists at linfiniti.com
Sun Oct 17 13:00:43 EDT 2010


Hi

I see that member is commented out in the sip file for rasterbandstats:

python/core/qgsrasterbandstats.sip

 40     //HistogramVector * histogramVector;

If I uncomment it I get a compile time error:

sip: QgsRasterBandStats::histogramVector has an unsupported type -
provide %GetCode and %SetCode
make[2]: *** [python/analysis/sipanalysispart0.cpp] Error 1
make[1]: *** [python/CMakeFiles/python_module_qgis_analysis.dir/all] Error 2

So I guess the sip bindings need some tweaking to make it work.

As an aside, if you are planning any tweaks improvements to the raster
historgram, it would be great to do it as a patch to existing
properties dialog rather than as a separate plugin. I found out how to
enable zoom (but I wont do it in time for 1.6 release) on the charts.
I also plan to add to the chart the user configured min/max entries
per band, and maybe later a way to interactively set them on the
chart.

Regards

Tim

On Sun, Oct 17, 2010 at 4:09 PM, Benoit de Cabissole <benoit at exigesa.com> wrote:
>  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
>
> _______________________________________________
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-developer
>



-- 
Tim Sutton - QGIS Project Steering Committee Member (Release  Manager)
==============================================
Please do not email me off-list with technical
support questions. Using the lists will gain
more exposure for your issues and the knowledge
surrounding your issue will be shared with all.

Visit http://linfiniti.com to find out about:
 * QGIS programming and support services
 * Mapserver and PostGIS based hosting plans
 * FOSS Consulting Services
Skype: timlinux
Irc: timlinux on #qgis at freenode.net
==============================================


More information about the Qgis-developer mailing list