Hot answers tagged

5

You can use something like the following: layer = qgis.utils.iface.activeLayer() provider = layer.dataProvider() ext = layer.extent() stats = provider.bandStatistics(1,QgsRasterBandStats.All,ext,0) print "minimum value = ", stats.minimumValue print "maximum value = ", stats.maximumValue print "mean = ", stats.mean print "stdDev = ", stats.stdDev Here ...


2

I got it: ##RED=raster ##a=number 0.0 ##XXX=output raster import numpy from qgis.analysis import QgsRasterCalculator, QgsRasterCalculatorEntry # Get layer object layer1 = processing.getObject(RED) # Get number number1 = a def xxx (RED,a,output): entries=[] #define raster 1 ("RED") raster1=QgsRasterCalculatorEntry() raster1.ref='RED@1' ...


1

I had to make minor changes to the script provided by @gcarrillo to include the OSGEO4W64 path (I had to re-install QGIS via the OSGEO4W64 installer as I used the standalone installer initially) and to include double-slashes. Here is the final script and many thanks to everyone for their help: import os, sys, glob # Prepare the environment from qgis.core ...



Only top voted, non community-wiki answers of a minimum length are eligible