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.
Any ideas? Thanks, JP On Fri, Sep 3, 2010 at 7:50 AM, JP Glutting <[email protected]> wrote: > Although here (http://blog.qgis.org/node/94) it seems to indicate that > SingleBandPseudoColor is a constant: > > mypLayer->setColorRampingType(QgsRasterLayer::BLUE_GREEN_RED); > mypLayer->setDrawingStyle(QgsRasterLayer::SINGLE_BAND_PSEUDO_COLOR); > std::deque myLayerSet; > > which is what I was thinking in the first place, and here ( > http://doc.qgis.org/stable/classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9 > ) > DrawingStyle is described as an enumerator, which seems coherent. I am not > sure how to do this from Python. > > Cheers, > JP > > On Fri, Sep 3, 2010 at 7:43 AM, JP Glutting <[email protected]> wrote: > >> Actually, I am not even sure that first part is the way to do it. I tried >> this: >> >> >> resultsLayer.setDrawingStyle(QtCore.QString('SingleBandPseudoColor')) >> resultsLayer.setCacheImage(None) >> resultsLayer.triggerRepaint() >> >> (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: >> >> myRasterLayer->setDrawingStyle<http://classQgsRasterLayer.html#3a923f732bedd87d0b920c5552215434> >> (QgsRasterLayer::SingleBandPseudoColor<http://classQgsRasterLayer.html#36796f1a303dac9848ba3dce3e5527dc7b7c9814c053986846b579119d2e5be9> >> ); >> >> (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): >> >> >> 00204 QgsRasterLayer <http://classQgsRasterLayer.html>( int dummy,00205 >> const QString & baseName = QString(),00206 >> const QString & path = QString(),00207 const >> QString & providerLib = QString(),00208 const >> QStringList & layers = QStringList(),00209 const >> QStringList & styles = QStringList(),00210 const QString >> & format = QString(), >> >> 00211 const QString & crs = QString() ); >> >> Thanks, >> JP >> >> On Fri, Sep 3, 2010 at 3:04 AM, JP Glutting <[email protected]> wrote: >> >>> Hello, >>> >>> 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: >>> >>> resultsLayer = qgis.core.QgsRasterLayer(self.query.results_file, >>> QtCore.QFileInfo(self.query.results_file).baseName()) >>> >>> qgis.core.QgsMapLayerRegistry.instance().addMapLayer(resultsLayer) >>> >>> >>> 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. >>> >>> I tried the psuedocolor with this code: >>> >>> >>> >>> resultsLayer.setDrawingStyle(qgis.core.QgsRasterLayer.SingleBandPseudoColor) >>> resultsLayer.setCacheImage(None) >>> resultsLayer.triggerRepaint() >>> >>> which doesn't seem to do anything at all, and I am just guessing, really. >>> >>> I found a nice tutorial about how to calculate the min and max extent of >>> a raster and adjust the display here: >>> >>> http://linfiniti.com/2010/08/a-simple-qgis-python-tutorial/ >>> >>> and I tried the following code: >>> >>> band = resultsLayer.bandNumber(resultsLayer.grayBandName()) >>> extentMin = 0.0 >>> extentMax = 0.0 >>> generateLookupTableFlag = False >>> extentMin, extentMax = >>> resultsLayer.computeMinimumMaximumFromLastExtent(band) >>> resultsLayer.setMinimumValue(band, extentMin, >>> generateLookupTableFlag) >>> resultsLayer.setMaximumValue(band, extentMax, >>> generateLookupTableFlag) >>> resultsLayer.setStandardDeviations(0.0) >>> resultsLayer.setUserDefinedGrayMinimumMaximum( True ) >>> resultsLayer.setCacheImage(None) >>> resultsLayer.triggerRepaint() >>> >>> but that fails with the following error: >>> >>> Traceback (most recent call last): >>> File "/Users//.qgis/python/plugins/mcelite/MCELiteDialog.py", line 361, >>> in accept >>> extentMin, extentMax = >>> resultsLayer.computeMinimumMaximumFromLastExtent(band) >>> TypeError: 'float' object is not iterable >>> >>> >>> and I don't understand what the float object is, exactly. >>> >>> >>> Any help or suggestions much appreciated. >>> >>> >>> Cheers, >>> >>> JP >>> >> >> >
_______________________________________________ Qgis-user mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/qgis-user
