New 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' ...


0

When running scripts, a good idea is to unload all the modules that were imported and remove any dependencies. This seemed to be what was causing your scripts to not work the way they should. Probably the easiest method to achieve the above is to simply restart QGIS.


0

I guess thoses layers are all rasters to begin with. You could find a way by importing qgis core and processing inside a Python shell. By doing this you can extract the selected items from qgis. For the processing afterwards you could use the gdal merge tool as if you were running an algorythm or calling a function. I must have a python code where i did ...


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 ...



Top 50 recent answers are included