Bug report #3807

QgsRasterLayer.identify() is always True

Added by Ricardo Silva over 9 years ago. Updated over 1 year ago.

Status:Closed
Priority:Low
Assignee:-
Category:Rasters
Affected QGIS version:master Regression?:No
Operating System: Easy fix?:No
Pull Request or Patch supplied:No Resolution:end of life
Crashes QGIS or corrupts data:No Copied to github as #:13865

Description

Using the python bindings, when trying to identify a point outside of current raster layer, The QgsRasterLayer.identify() method is returning:

(True, {PyQt4.QtCore.QString(u'Band 1'): PyQt4.QtCore.QString(u'out of extent')})

which doesn't make much sense IMO. If the result is the "out of extent" string, then the identifying has failed, so the first entry of the tuple should be False, instead of True.

History

#1 Updated by Ricardo Silva over 9 years ago

This is always true if the identified point is inside the extents of the raster layer, but in an area that is not part of the layer itself, in which case QgsRasterLayer.identify() returns:

(True, {PyQt4.QtCore.QString(u'Band 1'): PyQt4.QtCore.QString(u'null (no data)')})

I guess this is not intended behavior as well, because the tuple's first value is always True.

#2 Updated by Borys Jurgiel about 8 years ago

  • Affected QGIS version set to master
  • Crashes QGIS or corrupts data set to No
  • Pull Request or Patch supplied set to No
  • Assignee deleted (Borys Jurgiel)

#3 Updated by Jürgen Fischer over 6 years ago

  • Target version changed from Version 2.0.0 to Future Release - Lower Priority

#4 Updated by Médéric RIBREUX about 5 years ago

  • Category changed from Python plugins to Rasters
  • Tag set to easy
  • Operating System deleted (Debian)

Hello, bug triage...

this is still true in QGIS 2.13 even if the identification mechanism have changed. Today, we use identify method on the raster layer provider:

ident = rlayer.dataProvider().identify(QgsPoint(15.30, 40.98), QgsRaster.IdentifyFormatValue)
if ident.isValid()
  ident.results()

# When you are out of the raster extent, ident is valid but the results are: {1:None}

We need to make identify method returns a non valid QgsRasterIdentifyResult when identification is outside the extent of the raster. Currently, when you look at the code, when we are outside of the extent, QGIS still returns a valid QgsRasterIdentifyResult with a QVariant for each band of the raster. I think this is easy to fix as long as this does not break something else.

#5 Updated by Giovanni Manghi over 3 years ago

  • Regression? set to No
  • Easy fix? set to No

#6 Updated by Giovanni Manghi over 1 year ago

  • Resolution set to end of life
  • Status changed from Open to Closed

Also available in: Atom PDF