Hi Bob<div><br></div><div>On Thursday, October 6, 2011, Bob and Deb  wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p>Hello list,</p>
<p>Is there a way set the transparancy based on certain raster values?  I know that it can be done by setting the rasters Custom transparency options, but I would like to do it in Python.</p></blockquote><div><br></div><div>
This way you can access current list of transparency values:</div><div><br></div><div>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; rt=l.rasterTransparency()</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; lst = rt.transparentSingleValuePixelList()</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; for item in lst: print item.pixelValue, item.percentTransparent</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">... </p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">-9999.0 100.0</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">0.0 50.0</p></div><div><br></div><div>To set a list with just one value:</div><div><br></div><div>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; x = QgsRasterTransparency.TransparentSingleValuePixel()</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; x.pixelValue = 123</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; x.transparencyPercent = 50</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">&gt;&gt;&gt; rt.setTransparentSingleValuePixelList( [ x ] )</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">
<br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">The above examples suppose that you use single band raster. In case of RGB image the steps are similar, just instead of &quot;SingleValue&quot; methods you would use &quot;ThreeValue&quot; methods and instead of &quot;pixelValue&quot; attribute there are &quot;red&quot;, &quot;green&quot;, &quot;blue&quot; attributes.</p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "><br></p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">Martin</p><p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; ">
<br></p>
<p style="margin-top: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; "></p></div></div>