[QGIS-Developer] Wrong Output GetRasterband

Nyall Dawson nyall.dawson at gmail.com
Wed Jul 25 15:46:16 PDT 2018


On Thu, 26 Jul 2018 at 08:45, Nyall Dawson <nyall.dawson at gmail.com> wrote:
> This is GDAL api, not QGIS. If you want to try the QGIS way you should use:
>
> testlayer=iface.activeLayer()
> stats = testlayer.dataProvider().bandStatistics(1)
> print(stats.minimumValue)
> print(stats.maximumValue)

Just to expand on that - if you use pure PyQGIS API instead of mixing
in the gdal API here, then your code will work correctly regardless of
the layer source (e.g. it will work for wms/mapserver/etc, not just
gdal file based layers)

Nyall


More information about the QGIS-Developer mailing list