Have a look at the source of the value tool plugin, it calls the identify() method and has been updated to 2.0 api.<div><br></div><div>Etienne<br><br><div class="gmail_quote">On Thu, Aug 1, 2013 at 1:58 PM, Otto Dassau <span dir="ltr"><<a href="mailto:dassau@gbd-consult.de" target="_blank">dassau@gbd-consult.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I want to update a plugin from 1.8 to QGIS 2.0 and it throws following error:<br>
<br>
Traceback (most recent call last):<br>
File<br>
<br>
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",<br>
line 447, in printValue self.showValues() File<br>
<br>
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",<br>
line 453, in showValues self.plot() File<br>
<br>
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",<br>
line 514, in plot w = float(self.sampleRaster(self.InRastW.currentText(),<br>
self.xCoord, self.yCoord))/10 File<br>
<br>
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",<br>
line 299, in sampleRaster return self.sampleRaster20(layer, x, y) File<br>
<br>
"/home/dassau/.qgis2/python/plugins/weibullanalyse/weibullanalysedialog.py",<br>
line 284, in sampleRaster20 success, data =<br>
layer.dataProvider().identify(QgsPoint(x,y))<br>
<br>
TypeError:<br>
QgsRasterDataProvider.identify(QgsPoint, QgsRaster.IdentifyFormat,<br>
QgsRectangle theExtent=QgsRectangle(), int theWidth=0, int theHeight=0):<br>
not enough arguments<br>
<br>
I found at <a href="http://hub.qgis.org/wiki/quantum-gis/API_changes_for_version_20" target="_blank">http://hub.qgis.org/wiki/quantum-gis/API_changes_for_version_20</a><br>
the section QgsRasterDataProvider which should fit. And the Method, where I<br>
assume the error occurs should be this<br>
<br>
# get value at mouse position QGIS <= 1.8 (working for 1.8)<br>
def sampleRaster18(self, layer, x, y):<br>
   success, data = layer.identify(QgsPoint(x,y))<br>
   for band, value in data.items():<br>
     return value<br>
<br>
now what I tried but doesn't work (see error above)<br>
<br>
# get value at mouse position QGIS >= 2.0 (not working yet :()<br>
def sampleRaster20(self, layer, x, y):<br>
   success, data = layer.dataProvider().identify(QgsPoint(x,y))<br>
   for band, value in data.items():<br>
     return value<br>
<br>
my problem is, that I don't understand how to implement in sampleRaster20<br>
the new method from the API_changes_for_version_20 website which says:<br>
<br>
QMap<int, QVariant> identify( const QgsPoint & thePoint, IdentifyFormat<br>
theFormat, const QgsRectangle &theExtent = QgsRectangle(), int theWidth =<br>
0, int theHeight = 0 )<br>
<br>
can anybody help?<br>
<br>
Thanks<br>
<br>
Otto<br>
_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
</blockquote></div><br></div>