[QGIS-Developer] pyqgis:generate ColorRampItemList

Martin Dobias wonder.sk at gmail.com
Wed May 10 01:45:14 PDT 2017


Hi Martin

On Tue, May 9, 2017 at 11:34 PM, Martin Landa <landa.martin at gmail.com> wrote:
> Hi,
>
> example of raster single band renderer in pyqgis cookbook [1] is based
> on predefined list of color rules items. Is it possible to generate
> rules items automatically from defined min&max values, number of
> classes, and classification mode (same when user clicks on 'Classify'
> button)?

In QGIS master (will be 3.0) there is
QgsSingleBandPseudoColorRenderer::createShader(...) method to do that,
however in 2.x that code is not accessible through API... you could
however still port the underlying classification code to your plugin:
https://github.com/qgis/QGIS/blob/release-2_18/src/gui/raster/qgssinglebandpseudocolorrendererwidget.cpp#L345

Cheers
Martin


More information about the QGIS-Developer mailing list