No takers? No hints? I have been looking all over the place, and I am stuck. If it is something absurdly simple, just point me in the right direction.<div><br></div><div>Any ideas?</div><div><br></div><div>Thanks,</div><div>
JP<br><br><div class="gmail_quote">On Fri, Sep 3, 2010 at 7:50 AM, JP Glutting <span dir="ltr"><<a href="mailto:jpglutting@gmail.com">jpglutting@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
Although here (<a href="http://blog.qgis.org/node/94" target="_blank">http://blog.qgis.org/node/94</a>) it seems to indicate that SingleBandPseudoColor is a constant:<div><br></div><div><span style="font-family:Verdana, Arial, Helvetica, sans-serif;font-size:12.5px;border-collapse:collapse;line-height:20px"><pre style="background-color:rgb(238, 238, 238);padding-top:0.75em;padding-right:1.5em;padding-bottom:0.75em;padding-left:1.5em;font-size:12px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(221, 221, 221);border-right-color:rgb(221, 221, 221);border-bottom-color:rgb(221, 221, 221);border-left-color:rgb(221, 221, 221)">
mypLayer->setColorRampingType(QgsRasterLayer::BLUE_GREEN_RED);
  mypLayer->setDrawingStyle(QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR);
  std::deque myLayerSet;</pre></span><div>which is what I was thinking in the first place, and here ( <a href="http://doc.qgis.org/stable/classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9" target="_blank">http://doc.qgis.org/stable/classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9</a> ) DrawingStyle is described as an enumerator, which seems coherent. I am not sure how to do this from Python.</div>

<div><br></div><div>Cheers,</div><div>JP</div><div><div></div><div class="h5"><br><div class="gmail_quote">On Fri, Sep 3, 2010 at 7:43 AM, JP Glutting <span dir="ltr"><<a href="mailto:jpglutting@gmail.com" target="_blank">jpglutting@gmail.com</a>></span> wrote:<br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Actually, I am not even sure that first part is the way to do it. I tried this:</div><div><br></div><div><div>        resultsLayer.setDrawingStyle(QtCore.QString('SingleBandPseudoColor'))</div>

<div><div>        resultsLayer.setCacheImage(None)</div>
<div>        resultsLayer.triggerRepaint()</div></div></div><div><br></div><div>(passing the 'SingleBandPseudoColor' style as a string) and it makes the raster invisible. It still shows up black in the Layers Panel, but it doesn't show in the main window until you change the properties manually (and it is Grayscale when you do). It feels like I am pretty close, but I am not sure how to interpret this code from the QGIS documentation:</div>


<div><br></div><div><span style="font-family:monospace, fixed;font-size:13.3333px;white-space:pre-wrap">myRasterLayer-><a href="http://classQgsRasterLayer.html#3a923f732bedd87d0b920c5552215434" style="color:rgb(0, 0, 255);text-decoration:none;font-weight:normal" target="_blank">setDrawingStyle</a>(<a href="http://classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9" style="color:rgb(0, 0, 255);text-decoration:none;font-weight:normal" target="_blank">QgsRasterLayer::SingleBandPseudoColor</a>);</span></div>


<div><br></div><div><span style="font-family:monospace, fixed;font-size:13.3333px;white-space:pre-wrap"></span>(I never learned more than the basics of C++, and that was a long time ago). The source code seems to indicate that the format needs to be passed as a string (of course, when the layer is generated):</div>


<div><br></div><span style="font-family:monospace, fixed;font-size:11.6667px"><pre style="font-family:monospace, fixed;font-size:13px;border-top-width:1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;border-top-style:solid;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:rgb(204, 204, 204);border-right-color:rgb(204, 204, 204);border-bottom-color:rgb(204, 204, 204);border-left-color:rgb(204, 204, 204);background-color:rgb(245, 245, 245);margin-top:4px;margin-bottom:4px;margin-left:2px;margin-right:8px;padding-left:6px;padding-right:6px;padding-top:4px;padding-bottom:4px">
<br>00204     <a href="http://classQgsRasterLayer.html" style="color:rgb(0, 0, 255);text-decoration:none;font-weight:normal" target="_blank">QgsRasterLayer</a>( <span style="color:rgb(96, 64, 32)">int</span> dummy,
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00205" style="color:rgb(26, 65, 168)"></a>00205                     <span style="color:rgb(0, 128, 0)">const</span> QString & baseName = QString(),
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00206" style="color:rgb(26, 65, 168)"></a>00206                     <span style="color:rgb(0, 128, 0)">const</span> QString & path = QString(),
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00207" style="color:rgb(26, 65, 168)"></a>00207                     <span style="color:rgb(0, 128, 0)">const</span> QString & providerLib = QString(),
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00208" style="color:rgb(26, 65, 168)"></a>00208                     <span style="color:rgb(0, 128, 0)">const</span> QStringList & layers = QStringList(),
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00209" style="color:rgb(26, 65, 168)"></a>00209                     <span style="color:rgb(0, 128, 0)">const</span> QStringList & styles = QStringList(),
<a name="12ad6257a37c3c34_12ad61ec7902b935_l00210" style="color:rgb(26, 65, 168)"></a>00210                     <span style="color:rgb(0, 128, 0)">const</span> QString & format = QString(), </pre></span><div><span style="font-family:monospace, fixed;font-size:13.3333px;white-space:pre-wrap">00211                     <span style="color:rgb(0, 128, 0)">const</span> QString & crs = QString() );</span></div>


<div><br></div><div><span style="font-family:monospace, fixed;font-size:13.3333px;white-space:pre-wrap"></span>Thanks,</div><div>JP </div><div><div></div><div><br><div class="gmail_quote">On Fri, Sep 3, 2010 at 3:04 AM, JP Glutting <span dir="ltr"><<a href="mailto:jpglutting@gmail.com" target="_blank">jpglutting@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,
<div><br></div><div>I am working on a plugin (I mentioned it on the list earlier, but it isn't relevant to the question I have now). I have the results written to a raster file, and I need to display it. I am using this code:</div>



<div><br></div><div><div>        resultsLayer = qgis.core.QgsRasterLayer(self.query.results_file, QtCore.QFileInfo(self.query.results_file).baseName())</div><div>        qgis.core.QgsMapLayerRegistry.instance().addMapLayer(resultsLayer)</div>



</div><div><br></div><div><br></div><div>which works fine for opening the file, but I would like to fine-tune the display so the user doesn't have to reset the properties (in my test exaple the values are 0 and 1 and the display is essentially all black). I would like to either display the results in pseudocolor directly, or in grayscale with the scale stretched to the min and max extent of the raster.</div>



<div><br></div><div>I tried the psuedocolor with this code:</div><div><br></div><div><div>        resultsLayer.setDrawingStyle(qgis.core.QgsRasterLayer.SingleBandPseudoColor)</div><div>        resultsLayer.setCacheImage(None)</div>



<div>        resultsLayer.triggerRepaint()</div></div><div><br></div><div>which doesn't seem to do anything at all, and I am just guessing, really.</div><div><br></div><div>I found a nice tutorial about how to calculate the min and max extent of a raster and adjust the display here:</div>



<div><br></div><div><a href="http://linfiniti.com/2010/08/a-simple-qgis-python-tutorial/" target="_blank">http://linfiniti.com/2010/08/a-simple-qgis-python-tutorial/</a></div><div><br></div><div>and I tried the following code:</div>


<div>
<br></div><div><div>        band = resultsLayer.bandNumber(resultsLayer.grayBandName())</div><div>        extentMin = 0.0</div><div>        extentMax = 0.0</div><div>        generateLookupTableFlag = False</div><div>        extentMin, extentMax = resultsLayer.computeMinimumMaximumFromLastExtent(band)</div>



<div>        resultsLayer.setMinimumValue(band, extentMin, generateLookupTableFlag)</div><div>        resultsLayer.setMaximumValue(band, extentMax, generateLookupTableFlag)</div><div>        resultsLayer.setStandardDeviations(0.0)</div>



<div>        resultsLayer.setUserDefinedGrayMinimumMaximum( True )</div><div>        resultsLayer.setCacheImage(None)</div><div>        resultsLayer.triggerRepaint()</div></div><div><br></div><div>but that fails with the following error:</div>



<div><br></div><div>
<p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Traceback (most recent call last):<br>  File "/Users//.qgis/python/plugins/mcelite/MCELiteDialog.py", line 361, in accept<br>



    extentMin, extentMax = resultsLayer.computeMinimumMaximumFromLastExtent(band)<br>TypeError: 'float' object is not iterable<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">



<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">and I don't understand what the float object is, exactly.</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">



<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Any help or suggestions much appreciated.</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">



<br></p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">Cheers,</p><p style="margin-top:0px;margin-bottom:0px;margin-left:0px;margin-right:0px;text-indent:0px">
JP</p></div>
</blockquote></div><br>
</div></div></blockquote></div><br></div></div></div>
</blockquote></div><br></div>