[Qgis-user] Landsat RGB band ratio images with Qgis

Radim Blazek radim.blazek at gmail.com
Wed Oct 23 04:04:46 PDT 2013


On Mon, Oct 7, 2013 at 6:14 PM, BLANDENIER Lucien
<lucien.blandenier at unine.ch> wrote:
> Dear all,
>
> I would like to know if there a possibility to make some RGB band ratio with Landsat images, like (5/3, 5/1, 7/5).

You can write you own renderer in Python, example:

from PyQt4.QtGui import QColor
from qgis.core import *
from qgis.utils import iface

class MyRenderer ( QgsRasterRenderer ):
  def __init__( self ):
    QgsRasterRenderer.__init__(self)

  def block ( self, bandNo, extent, width, height ):
    block2 = self.input().block ( 2, extent, width, height )
    block3 = self.input().block ( 3, extent, width, height )
    block4 = self.input().block ( 4, extent, width, height )
    block = QgsRasterBlock ( QGis.ARGB32_Premultiplied, width, height, 0 );
    for r in range(0,height):
      for c in range(0,width):
        v2 = block2.value( r, c )
        v3 = block3.value( r, c )
        v4 = block4.value( r, c )
        color = QColor ( v4, v3, v2 )
        block.setColor( r, c, color.rgb() )
    return block

renderer = MyRenderer()
iface.activeLayer().pipe().set( renderer )

In the renderer you can blend colors like you want.

This is somewhat experimental, it won't be saved in project, you
cannot change params of your renderer in properties GUI.

Radim

> I searched on Internet but found nothing relevant.
>
>
> Regards
>
>
> Lucien
> _______________________________________________
> Qgis-user mailing list
> Qgis-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/qgis-user



More information about the Qgis-user mailing list