[Qgis-developer] update plugin to QGIS 2.0
Otto Dassau
dassau at gbd-consult.de
Fri Aug 2 03:13:29 PDT 2013
Hi,
thanks for your hints, I think I am on the right track now. I had a look at
the value tool plugin and tried to adapt the method accordingly:
def sampleRaster20(self, layer, x, y):
#success, data = layer.dataProvider().identify(QgsPoint(x,y))
success, data = layer.dataProvider().identify(QgsPoint(x,y),QgsRaster.IdentifyFormatValue).results()
for band, value in data.items():
return value
But now I get another error message
File
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
line 448, in printValue self.showValues() File
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
line 454, in showValues self.plot() File
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
line 526, in plot w = float(self.sampleRaster(self.InRastW.currentText(),
self.xCoord, self.yCoord))/10 File
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
line 300, in sampleRaster return self.sampleRaster20(layer, x, y) File
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
line 285, in sampleRaster20 success, data =
layer.dataProvider().identify(QgsPoint(x,y), QgsRaster.IdentifyFormatValue
).results() ValueError: need more than 1 value to unpack
Do you have an idea for this, too?
Thanks
Otto
Am Thu, 1 Aug 2013 16:00:08 -0300
schrieb Etienne Tourigny <etourigny.dev at gmail.com>:
> Have a look at the source of the value tool plugin, it calls the identify()
> method and has been updated to 2.0 api.
>
> Etienne
>
> On Thu, Aug 1, 2013 at 1:58 PM, Otto Dassau <dassau at gbd-consult.de> wrote:
>
> > Hi,
> >
> > I want to update a plugin from 1.8 to QGIS 2.0 and it throws following
> > error:
> >
> > Traceback (most recent call last):
> > File
> >
> >
> > "/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
> > line 447, in printValue self.showValues() File
> >
> >
> > "/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
> > line 453, in showValues self.plot() File
> >
> >
> > "/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
> > line 514, in plot w = float(self.sampleRaster(self.InRastW.currentText(),
> > self.xCoord, self.yCoord))/10 File
> >
> >
> > "/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
> > line 299, in sampleRaster return self.sampleRaster20(layer, x, y) File
> >
> >
> > "/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",
> > line 284, in sampleRaster20 success, data =
> > layer.dataProvider().identify(QgsPoint(x,y))
> >
> > TypeError:
> > QgsRasterDataProvider.identify(QgsPoint, QgsRaster.IdentifyFormat,
> > QgsRectangle theExtent=QgsRectangle(), int theWidth=0, int theHeight=0):
> > not enough arguments
> >
> > I found at
> > http://hub.qgis.org/wiki/quantum-gis/API_changes_for_version_20 the
> > section QgsRasterDataProvider which should fit. And the Method, where I
> > assume the error occurs should be this
> >
> > # get value at mouse position QGIS <= 1.8 (working for 1.8)
> > def sampleRaster18(self, layer, x, y):
> > success, data = layer.identify(QgsPoint(x,y))
> > for band, value in data.items():
> > return value
> >
> > now what I tried but doesn't work (see error above)
> >
> > # get value at mouse position QGIS >= 2.0 (not working yet :()
> > def sampleRaster20(self, layer, x, y):
> > success, data = layer.dataProvider().identify(QgsPoint(x,y))
> > for band, value in data.items():
> > return value
> >
> > my problem is, that I don't understand how to implement in sampleRaster20
> > the new method from the API_changes_for_version_20 website which says:
> >
> > QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat
> > theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth =
> > 0, int theHeight = 0 )
> >
> > can anybody help?
> >
> > Thanks
> >
> > Otto
> > _______________________________________________
> > Qgis-developer mailing list
> > Qgis-developer at lists.osgeo.org
> > http://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
--
Geoinformatik Büro Dassau - http://www.gbd-consult.de
FOSSGIS consulting , training , support and analysis
Ackerstrasse 144c , D - 40233 Düsseldorf , Germany
Tel: +49-(0)211-47468178 , Mobil: +49-(0)171-4687540
--
Community Advisor - QGIS Project Steering Committee
More information about the Qgis-developer
mailing list