<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
JP,<br>
<br>
In version 1.5 the python bindings were not correct. Python could not
use the computeMinMaxFormLastExtent(int, double*) so the new method
computeMinMaxFromLastExtent(int, double, double) was added.<br>
<br>
Since you are running on windows, you could install the "nighly-build"
QGIS package which would give you the developers version 1.6 and would
not require you or your professor to compile manually. This would have
all of the updated python bindings and newest methods mentioned in the
responses.<br>
<br>
-pete<br>
<br>
On 09/07/2010 11:04 AM, JP Glutting wrote:
<blockquote
 cite="mid:AANLkTin4LnLPR_M+8PnS-5d3UCtggDkg9kfT0eSh9w09@mail.gmail.com"
 type="cite">No, sorry, my mistake, I was mixing up the documentation.
computeMinMaxFromLastExtent doesn't seem to be available at all in 1.5.
  <div><br>
  </div>
  <div>However, when I use&nbsp;computeMinMaxFromLastExtent(int), the
interpreter does not complain, but does nothing. When I
try&nbsp;computeMinMaxFromLastExtent(int, double), I get the following error:</div>
  <div><br>
  </div>
  <div>
  <p style="margin: 0px; text-indent: 0px;">TypeError:
QgsRasterLayer.computeMinimumMaximumFromLastExtent(): arguments did not
match any overloaded call:<br>
&nbsp; overload 1: too many arguments<br>
&nbsp; overload 2: argument 1 has unexpected type 'int'</p>
  <p style="margin: 0px; text-indent: 0px;"><br>
  </p>
  <p style="margin: 0px; text-indent: 0px;">In any case, it appears
that I am out of my depth with this, and should probably avoid using
this function until it makes it into the stable version.</p>
  <p style="margin: 0px; text-indent: 0px;"><br>
  </p>
  <p style="margin: 0px; text-indent: 0px;">Cheers,</p>
  <p style="margin: 0px; text-indent: 0px;">JP</p>
  <br>
  <div class="gmail_quote">On Tue, Sep 7, 2010 at 4:51 PM, JP Glutting <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:jpglutting@gmail.com">jpglutting@gmail.com</a>&gt;</span>
wrote:<br>
  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi
Pete,
    <div><br>
    </div>
    <div>Thanks for the clarification. I am doing a bit of creative
interpretation of the QGIS API for python, as I am only passingly
familiar with C++. It never occurred to me that passing a parameter to
a function would change change its value (or declare it). If I am
interpreting you correctly, by passing minVal to
computeMinimumMaximumFromLastExtent (in QGIS 1.6), that variable would
be created with the actual minimum value of the extent. Interesting.
(When I said "set", I meant register them in some place, where they
could be accessed by something like &nbsp;resultsLayer.minimumValue(). My
understanding was that the actual minimum and maximum values were not
calculated initially to save computing power, so that
computeMinimumMaximumFromLastExtent was actually determining a value,
which was then recorded ("set") somewhere.&nbsp;</div>
    <div><br>
    </div>
    <div>I was aware of&nbsp;setMinimumMaximumFromLastExtent() and how it
works, so the error was mine in muddling the two terms.</div>
    <div><br>
    </div>
    <div>I am using QGIS 1.5 (on OS X and Win7) using python 2.6, so
these may not work for me. Since I am submitting this project for a
class, and we are encouraged to make our plugin with the basic
functionality of the packages involved, I would guess that asking my
professors to compile from the SVN trunk in order to grade my
assignment would not make a very good impression on them. So I will
just stick to the 1.5 functionality, I guess.</div>
    <div><br>
    </div>
    <div>To see if I have my ideas clear, my understanding from the
documentation is that the only version
of&nbsp;computeMinimumMaximumFromLastExtent which is new to 1.6
is&nbsp;computeMinimumMaximumFromLastExtent(int band, double min, double
max) [the one you are talking about]. A similar
function&nbsp;computeMinimumMaximumFromLastExtent(int, double theMinMax)
seems to be available, although I was under the impression that the
function accepted a parameter of the *estimated* minmax from another
function. I am guessing that the correct idea is that, after calling
this function, "theMinMax" holds the two values (or estimates,
according to the documentation), although I am also unclear on how a
single double holds two values, exactly.&nbsp;</div>
    <div><br>
    </div>
    <div>I am going to fiddle around with the code a little and see if
I can understand this better.</div>
    <div><br>
    </div>
    <div>Thanks for all the info,</div>
    <div>JP</div>
    <div>
    <div class="h5">
    <div><br>
    <div class="gmail_quote">On Tue, Sep 7, 2010 at 3:42 PM, Peter
Ersts <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:ersts@amnh.org" target="_blank">ersts@amnh.org</a>&gt;</span>
wrote:<br>
    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
      <div bgcolor="#ffffff" text="#000000">
JP,<br>
      <br>
the computeMinimumMaximumFromLastExtent() methods _do not set_ minimum
and maximum values, they return them for you to use how you want. Using
your variables names from below, you would want to use:<br>
      <br>
resultsLayer.computeMinimumMaximumFromLastExtent( band, minVal, maxVal )<br>
      <br>
After this call, your local variables minVal and maxVal would have
values of 0 and 1 respectively. There is another convenience function
called setMinimumMaximumUsingLastExtent(). This will _set_ the internal
minimum maximum values of the band(s) currently being displayed.<br>
      <br>
However, you have not indicated which version of QGIS you are using, so
both of these functions that I have mentioned may no be available to
you. You would need to be compiling QGIS from the svn trunk (v1.6) to
have access to these two functions.<br>
      <br>
-pete
      <div>
      <div><br>
      <br>
On 09/07/2010 08:33 AM, JP Glutting wrote:
      <blockquote type="cite">Hi Peter,
        <div><br>
        </div>
        <div>Thanks for the response. Sorry if I wasn't clear - there
was no
real question at this point, I was just following up on my previous
question with the resolution of the problem, mostly for the users list,
and I copied the message to the developers list as well, just for
completeness.&nbsp;</div>
        <div><br>
        </div>
        <div>However, the information about when and how Mins and Maxes
can
be calculated is interesting. I am not sure
that&nbsp;computeMinimumMaximumFromLastExtent is what I want - I was using
code form a plugin that was adjusting the color scheme for the visible
extent, not the whole layer (which is what I want to do). Where does it
store the result? This code:</div>
        <div><br>
        </div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;QgsMapLayerRegistry.instance().addMapLayer(resultsLayer)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.triggerRepaint()</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;band =
resultsLayer.bandNumber(resultsLayer.grayBandName()) #Should be 1</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;minVal = resultsLayer.minimumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;maxVal = resultsLayer.maximumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;QtGui.QMessageBox.information(self, <a
 moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("MinMax"),
        <a moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("Min:
%s Max
%s:" %(minVal, maxVal)))</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.computeMinimumMaximumFromLastExtent(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;minVal = resultsLayer.minimumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;maxVal = resultsLayer.maximumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;QtGui.QMessageBox.information(self, <a
 moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("MinMax"),
        <a moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("Min:
%s Max
%s:" %(minVal, maxVal)))</div>
        <div><br>
        </div>
        <div>Produces the same values (0.0 and 255.0) for a raster with
values of 0 and 1 before and after
calling&nbsp;computeMinimumMaximumFromLastExtent.</div>
        <div><br>
        </div>
        <div>Calling this next:</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.setContrastEnhancementAlgorithm(QgsContrastEnhancement.StretchToMinimumMaximum)</div>
        <div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;minVal = resultsLayer.minimumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;maxVal = resultsLayer.maximumValue(band)</div>
        <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;QtGui.QMessageBox.information(self, <a
 moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("MinMax"),
        <a moz-do-not-send="true" href="http://self.tr" target="_blank">self.tr</a>("Min:
%s Max
%s:" %(minVal, maxVal)))</div>
        </div>
        <div><br>
        </div>
        <div>stretches the grayscale colormap to 0 and 1, with the
layer
properties (from the GUI) Min and Max set to 0 and 1, so I assume that
it is computing the real values itself, I can't quite follow the
internals. Without this call, the properties window in the GUI shows 0
and 255 for min and max, even after
calling&nbsp;computeMinimumMaximumFromLastExtent (I can't seem to find a way
to figure out if this call does anything at all - I can't find any
values or results that indicate any effect, although I am probably
looking in the wrong place).</div>
        <div><br>
        </div>
        <div>Of course, the MessageBox continues to report 0 and 255,
so I
not sure where the correct information is stored.</div>
        <div><br>
        </div>
        <div>The tip on using the PseudoColorShader was exactly what I
needed, thank you. I knew it was just something simple I was going at
wrong.</div>
        <div><br>
        </div>
        <div>Anyway, my plug-in works very nicely now, and I will add
it to
the QGIS repository here in a few weeks when I hand in my assignment.&nbsp;</div>
        <div><br>
        </div>
        <div>Cheers,</div>
        <div>JP</div>
        <div><br>
        <div class="gmail_quote">On Tue, Sep 7, 2010 at 3:12 AM, Peter
Ersts <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:ersts@amnh.org" target="_blank">ersts@amnh.org</a>&gt;</span>
wrote:<br>
        <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
          <div bgcolor="#ffffff" text="#000000">Howdy JP,<br>
          <br>
Not quite sure what the question is at this stage. However, here are
some general comments. <br>
          <br>
When the raster is first loaded, the min max values for each band are
provided by GDAL but are estimates. You will not get the exact min max
values until the band statistics are generated, which depending on the
size of the image can take be slow. The raster has to be rendered at
least once for computeMinimumMaximumFromLastExtent() to provide
meaningful values.<br>
          <br>
Re:
          <div><br>
"On the other hand, <br>
resultsLayer.setColorShadingAlgorithm("PseudoColorShader")<br>
Doesn't seem to do anything at all. Strange."<br>
          </div>
          <div><br>
Pseudo color shading does not just use the minimum and maximum values,
it requires you to define the number of standard deviations to apply.
Also the pseudo color shader has to be used with the correct drawing
style, i.e., QgsRasterLayer.SingleBandPseudoColor<br>
          </div>
          <br>
          <br>
-pete
          <div>
          <div><br>
          <br>
On 09/05/2010 10:52 AM, JP Glutting wrote: </div>
          </div>
          <blockquote type="cite">
            <div>
            <div>
            <div class="gmail_quote">Ok, I figured this out. It was as
simple
as:
            <div><br>
            </div>
            <div><b>resultsLayer.setContrastEnhancementAlgorithm(QgsContrastEnhancement.StretchToMinimumMaximum)</b></div>
            <div><br>
            </div>
            <div>That computes the min and max, and stretches the
grayscale
(to
black and white for boolean rasters).</div>
            <div><br>
            </div>
            <div>In the mean time I was futzing around with:</div>
            <div>
            <div><br>
            </div>
            <div>
            <div>&nbsp;&nbsp; &nbsp; &nbsp; <b>&nbsp;band =
resultsLayer.bandNumber(resultsLayer.grayBandName())&nbsp;</b></div>
            </div>
            </div>
            <div>
            <div><b>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;minVal = resultsLayer.minimumValue(band)</b></div>
            <div><b>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;maxVal = resultsLayer.maximumValue(band)</b></div>
            <div><br>
            </div>
            <div>and</div>
            <div><br>
            </div>
            <div>
            <div>&nbsp;&nbsp; &nbsp; &nbsp;<b> &nbsp;resultsLayer.setMinimumValue(band, minVal,
generateLookupTableFlag)</b></div>
            <div><b>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setMaximumValue(band, maxVal,
generateLookupTableFlag)</b></div>
            </div>
            <div><br>
            </div>
            <div>but it turns out that &nbsp;<b>resultsLayer.</b><b>setMaximumValue(band)


            </b>returns the theoretical maximum (255) rather than the
real
maximum (1), which is not what I wanted. You can get the correct value
with</div>
            <div><br>
            </div>
            <div><b>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;maxVal =
resultsLayer.bandStatistics(band).maximumValue</b></div>
            <div><br>
            </div>
            <div>However, it says that calling bandStatistics is very
CPU
intensive, since it also calculates a lot of other stuff. As it turns
out, the StretchToMinimumMaximum algorithm seems to calculate the
minmax anyway, so none of that is needed.</div>
            <div><br>
            </div>
            <div>My big mistake, as I was rushing through this, was to
confuse
extent and values, as I was trying to copy from a tutorial and wasn't
paying close attention. Once I figured that out, it was easy.</div>
            <div><br>
            </div>
            <div>On the other hand,&nbsp;</div>
            <div><br>
            </div>
            <div><b>resultsLayer.setColorShadingAlgorithm("PseudoColorShader")</b></div>
            <div><br>
            </div>
            <div>Doesn't seem to do anything at all. Strange.</div>
            <div> <br>
            </div>
            <div>Cheers,</div>
            <div>JP</div>
            <br>
            <div class="gmail_quote">
            <div>On Sat, Sep 4, 2010 at 6:35 PM, Benoit de Cabissole <span
 dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:benoit@exigesa.com" target="_blank">benoit@exigesa.com</a>&gt;</span>
wrote:<br>
            </div>
            <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
              <div>
              <div>
              <div>
              <div><font color="#0000ff" face="Arial"><span>Hi JP,</span></font></div>
              <div><font color="#0000ff" face="Arial"><span></span></font>&nbsp;</div>
              <div><font color="#0000ff" face="Arial"><span>I would
suggest
asking your question on the Qgis-developer list instead of this one.</span></font></div>
              <div><font color="#0000ff" face="Arial"><span></span></font>&nbsp;</div>
              <div><font color="#0000ff" face="Arial"><span>Below&nbsp;is
what
I've
done to display a custom colormap on a raster. Could it be adapted to
your problem?</span></font></div>
              <div><font color="#0000ff" face="Arial"><span></span></font>&nbsp;</div>
              <div><font color="#0000ff" face="Arial"><span>&nbsp;&nbsp;&nbsp;&nbsp; <font
 color="#008000"># Display the raster with the selected colour table:<br>
&nbsp;&nbsp;&nbsp;&nbsp; #<br>
&nbsp;&nbsp;&nbsp;&nbsp; # - tell the layer to use a QgsColorRampShader function<br>
              </font>&nbsp;&nbsp;&nbsp;&nbsp; theLayer.setColorShadingAlgorithm(
QgsRasterLayer.ColorRampShader )<br>
&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"># - get a pointer to the raster shader
function (QgsColorRampShader)<br>
              </font>&nbsp;&nbsp;&nbsp;&nbsp; myColorRampShader =
theLayer.rasterShader().rasterShaderFunction()<br>
&nbsp;&nbsp;&nbsp;&nbsp; <font color="#008000"># - set parameters for the
QgsColorRampShader function</font><br>
&nbsp;&nbsp;&nbsp;&nbsp; myColorRampShader.setColorRampType( QgsColorRampShader.DISCRETE )<br>
&nbsp;&nbsp;&nbsp;&nbsp; myColorRampShader.setColorRampItemList( theTBL )<br>
&nbsp;&nbsp;&nbsp;&nbsp; theLayer.setDrawingStyle( QgsRasterLayer.SingleBandPseudoColor )<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000"> # - refresh map &amp; legend<br>
              </font>&nbsp;&nbsp;&nbsp;&nbsp; if hasattr(theLayer, "setCacheImage"): </span></font></div>
              <div><font color="#0000ff" face="Arial"><span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
theLayer.setCacheImage( None )<br>
&nbsp;&nbsp;&nbsp;&nbsp; theLayer.triggerRepaint()<br>
&nbsp;&nbsp;&nbsp;&nbsp; self.iface.legendInterface().refreshLayerSymbology( theLayer )<br>
&nbsp;&nbsp;&nbsp;&nbsp;<font color="#008000"> # - tell QGIS that it needs to ask user to
save changes<br>
              </font>&nbsp;&nbsp;&nbsp;&nbsp; self.iface.mapCanvas().setDirty( True )<br>
              </span></font></div>
              <div><font color="#0000ff" face="Arial"><span>Cheers,</span></font></div>
              <div><font color="#0000ff" face="Arial"><span>Benoit</span></font></div>
              <div>
              <div>
              <div><font color="#0000ff" face="Arial"><span>&nbsp;</span></font></div>
              <blockquote dir="ltr"
 style="border-left: 2px solid rgb(0, 0, 255); padding-left: 5px; margin-left: 5px; margin-right: 0px;">
                <div dir="ltr" align="left"><font face="Tahoma" size="2">-----Original
Message-----<br>
                <b>From:</b> <a moz-do-not-send="true"
 href="mailto:qgis-user-bounces@lists.osgeo.org" target="_blank">qgis-user-bounces@lists.osgeo.org</a>
[mailto:<a moz-do-not-send="true"
 href="mailto:qgis-user-bounces@lists.osgeo.org" target="_blank">qgis-user-bounces@lists.osgeo.org</a>]<b>On
Behalf
Of
                </b>JP Glutting<br>
                <b>Sent:</b> Saturday, 04 September 2010 17:47<br>
                <b>To:</b> <a moz-do-not-send="true"
 href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
                <b>Subject:</b> [Qgis-user] Re: Raster layer display
control
from
Plugin<br>
                <br>
                </font></div>
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">&lt;<a moz-do-not-send="true"
 href="mailto:jpglutting@gmail.com" target="_blank">jpglutting@gmail.com</a>&gt;</span>
wrote:<br>
                <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; padding-left: 1ex;">Although
here
(<a moz-do-not-send="true" 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-size: 12px; line-height: 20px; font-family: Verdana,Arial,Helvetica,sans-serif; border-collapse: collapse;">
                  <pre
 style="border: 1px solid rgb(221, 221, 221); padding: 0.75em 1.5em; font-size: 12px; background-color: rgb(238, 238, 238);">mypLayer-&gt;setColorRampingType(QgsRasterLayer::BLUE_GREEN_RED);
  mypLayer-&gt;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 moz-do-not-send="true"
 href="http://doc.qgis.org/stable/classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9"
 target="_blank">http://doc.qgis.org/stable/classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9</a>&nbsp;)
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><br>
                  <div class="gmail_quote">On Fri, Sep 3, 2010 at 7:43
AM, JP
Glutting <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:jpglutting@gmail.com" target="_blank">jpglutting@gmail.com</a>&gt;</span>
wrote:<br>
                  <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; 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>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.setDrawingStyle(QtCore.QString('SingleBandPseudoColor'))</div>
                    <div>
                    <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setCacheImage(None)</div>
                    <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;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-size: 13px; font-family: monospace,fixed;">myRasterLayer-&gt;<a
 moz-do-not-send="true"
 style="font-weight: normal; color: rgb(0, 0, 255); text-decoration: none;"
 href="http://classQgsRasterLayer.html#3a923f732bedd87d0b920c5552215434"
 target="_blank">setDrawingStyle</a>(<a moz-do-not-send="true"
 style="font-weight: normal; color: rgb(0, 0, 255); text-decoration: none;"
 href="http://classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9"
 target="_blank">QgsRasterLayer::SingleBandPseudoColor</a>);</span></div>
                    <div><br>
                    </div>
                    <div><span
 style="font-size: 13px; font-family: monospace,fixed;"></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-size: 11px; font-family: monospace,fixed;">
                    <pre
 style="border: 1px solid rgb(204, 204, 204); margin: 4px 8px 4px 2px; padding: 4px 6px; font-size: 13px; font-family: monospace,fixed; background-color: rgb(245, 245, 245);">00204     <a
 moz-do-not-send="true"
 style="font-weight: normal; color: rgb(0, 0, 255); text-decoration: none;"
 href="http://classQgsRasterLayer.html" target="_blank">QgsRasterLayer</a>( <span
 style="color: rgb(96, 64, 32);">int</span> dummy,
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00205"></a>00205                     <span
 style="color: rgb(0, 128, 0);">const</span> QString &amp; baseName = QString(),
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00206"></a>00206                     <span
 style="color: rgb(0, 128, 0);">const</span> QString &amp; path = QString(),
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00207"></a>00207                     <span
 style="color: rgb(0, 128, 0);">const</span> QString &amp; providerLib = QString(),
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00208"></a>00208                     <span
 style="color: rgb(0, 128, 0);">const</span> QStringList &amp; layers = QStringList(),
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00209"></a>00209                     <span
 style="color: rgb(0, 128, 0);">const</span> QStringList &amp; styles = QStringList(),
<a moz-do-not-send="true" style="color: rgb(26, 65, 168);"
 name="12aecae0b4f1b569_12aec6ebf92978e8_12aeb6f4c6ecc467_12ae9c0e4dc49526_12ae2611cd218532_12add9b15e2d46b2_12ad6257a37c3c34_12ad61ec7902b935_l00210"></a>00210                     <span
 style="color: rgb(0, 128, 0);">const</span> QString &amp; format = QString(),&nbsp;</pre>
                    </span>
                    <div><span
 style="font-size: 13px; font-family: monospace,fixed;">00211 <span
 style="color: rgb(0, 128, 0);">const</span> QString &amp; crs =
QString() );</span></div>
                    <div><br>
                    </div>
                    <div><span
 style="font-size: 13px; font-family: monospace,fixed;"></span>Thanks,</div>
                    <div>JP&nbsp;</div>
                    <div>
                    <div><br>
                    <div class="gmail_quote">On Fri, Sep 3, 2010 at
3:04 AM,
JP
Glutting <span dir="ltr">&lt;<a moz-do-not-send="true"
 href="mailto:jpglutting@gmail.com" target="_blank">jpglutting@gmail.com</a>&gt;</span>
wrote:<br>
                    <blockquote class="gmail_quote"
 style="border-left: 1px solid rgb(204, 204, 204); margin: 0px 0px 0px 0.8ex; 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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer =
qgis.core.QgsRasterLayer(self.query.results_file,
QtCore.QFileInfo(self.query.results_file).baseName())</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;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>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.setDrawingStyle(qgis.core.QgsRasterLayer.SingleBandPseudoColor)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setCacheImage(None)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;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 moz-do-not-send="true"
 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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;band =
resultsLayer.bandNumber(resultsLayer.grayBandName())</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;extentMin = 0.0</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;extentMax = 0.0</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;generateLookupTableFlag = False</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;extentMin, extentMax =
resultsLayer.computeMinimumMaximumFromLastExtent(band)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setMinimumValue(band,
extentMin,
generateLookupTableFlag)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setMaximumValue(band,
extentMax,
generateLookupTableFlag)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.setStandardDeviations(0.0)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp;
&nbsp;resultsLayer.setUserDefinedGrayMinimumMaximum(
True )</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.setCacheImage(None)</div>
                      <div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;resultsLayer.triggerRepaint()</div>
                      </div>
                      <div><br>
                      </div>
                      <div>but that fails with the following error:</div>
                      <div><br>
                      </div>
                      <div>
                      <p style="margin: 0px; text-indent: 0px;">Traceback
(most
recent
call last):<br>
&nbsp; File "/Users//.qgis/python/plugins/mcelite/MCELiteDialog.py", line
361, in accept<br>
&nbsp; &nbsp; extentMin, extentMax =
resultsLayer.computeMinimumMaximumFromLastExtent(band)<br>
TypeError: 'float' object is not iterable<br>
                      </p>
                      <p style="margin: 0px; text-indent: 0px;"><br>
                      </p>
                      <p style="margin: 0px; text-indent: 0px;">and I
don't
understand what the float object is, exactly.</p>
                      <p style="margin: 0px; text-indent: 0px;"><br>
                      </p>
                      <p style="margin: 0px; text-indent: 0px;">Any
help or
suggestions much appreciated.</p>
                      <p style="margin: 0px; text-indent: 0px;"><br>
                      </p>
                      <p style="margin: 0px; text-indent: 0px;">Cheers,</p>
                      <p style="margin: 0px; text-indent: 0px;">JP</p>
                      </div>
                    </blockquote>
                    </div>
                    <br>
                    </div>
                    </div>
                  </blockquote>
                  </div>
                  <br>
                  </div>
                  </div>
                  </div>
                </blockquote>
                </div>
                <br>
                </div>
              </blockquote>
              </div>
              </div>
              </div>
              <br>
              </div>
              </div>
            </blockquote>
            </div>
            </div>
            </div>
            </div>
            </div>
          </blockquote>
          </div>
        </blockquote>
        </div>
        </div>
      </blockquote>
      </div>
      </div>
      </div>
    </blockquote>
    </div>
    </div>
    </div>
    </div>
  </blockquote>
  </div>
  </div>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
====================================
Peter J. Ersts, Software Developer
American Museum of Natural History
Center for Biodiversity and Conservation
Central Park West at 79th Street
New York, New York 10024
Web: <a class="moz-txt-link-freetext" href="http://biodiversityinformatics.amnh.org">http://biodiversityinformatics.amnh.org</a>
Web: <a class="moz-txt-link-freetext" href="http://cbc.amnh.org">http://cbc.amnh.org</a>

Open Source,
...evolving through community cooperation to change the world bit by bit

Quantum GIS Raster Development Team. 
</pre>
</body>
</html>