Bug report #4806

Wrong legends/ramps for rasters

Added by Giovanni Manghi over 12 years ago. Updated over 11 years ago.

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

Description

Steps:

  • add the attached raster (is a DEM)
  • calculate the "aspect" map with the terrain analysis tool or with the gdaldem tool

The min/max values of the output are

STATISTICS_MINIMUM=0
STATISTICS_MAXIMUM=359.87353515625

but the legend will show values as

-9.8
398.8

which do not make any sense (see attached screenshot)

Another example is if you reclassify (with the raster calculator) the same DEM to a map with just "0" and "1"

  • (dem_clipped@1>300)*1 + (dem_clipped@1<=300)*0

the resulting map will show a legend with values as

0.3
1.4

that once again do not make any sense.

dem_clipped.tif (498 KB) Giovanni Manghi, 2012-01-13 07:51 AM

26.png (576 KB) Giovanni Manghi, 2012-01-13 07:51 AM

dem_clipped.tif (498 KB) Giovanni Manghi, 2012-01-22 06:11 AM

History

#1 Updated by Alexander Bruy over 12 years ago

Not reproducible here with latest qgis-dev (-37) from OSGeo4W under 32bit Windows XP Pro SP3. Also tested under 32bit Slackware 13.37 with latest master (4413a7d), GDAL 1.9.0 with same result — not reproducible.

#2 Updated by Giovanni Manghi over 12 years ago

Alexander Bruy wrote:

Not reproducible here with latest qgis-dev (-37) from OSGeo4W under 32bit Windows XP Pro SP3. Also tested under 32bit Slackware 13.37 with latest master (4413a7d), GDAL 1.9.0 with same result — not reproducible.

Hi Alexander, that's weird, I also tested qgis master on both Windows and Linux. Do you mean that you are getting legends with the expected values?

#3 Updated by Alexander Bruy over 12 years ago

Giovanni Manghi wrote:

Hi Alexander, that's weird, I also tested qgis master on both Windows and Linux. Do you mean that you are getting legends with the expected values?

Right, I get correct legend values. In case with reclassified DEM this is 0 and 1. In case with "aspect" analysis results this is 0.14579 and 360. Maybe this is because you use 64bit system?

#4 Updated by Giovanni Manghi over 12 years ago

Alexander Bruy wrote:

Giovanni Manghi wrote:

Hi Alexander, that's weird, I also tested qgis master on both Windows and Linux. Do you mean that you are getting legends with the expected values?

Right, I get correct legend values. In case with reclassified DEM this is 0 and 1. In case with "aspect" analysis results this is 0.14579 and 360. Maybe this is because you use 64bit system?

My Linux box is 64 bit but my Windows VM is 32 bit, so should be something else. But what?

#5 Updated by Paolo Cavallini over 12 years ago

Confirmed here on Debian unstable 64bit (values from -8 to +399)

#6 Updated by Giovanni Manghi over 12 years ago

But I'm sure I got the same also on a 32bit system...

#7 Updated by Giovanni Manghi over 12 years ago

loading the attached raster (dem_lipped.tif), without applying any particular color map, in the legend I see a "-32767-32768" that I also don't uderstand

#8 Updated by Alexander Bruy over 12 years ago

Giovanni Manghi wrote:

loading the attached raster (dem_lipped.tif), without applying any particular color map, in the legend I see a "-32767-32768" that I also don't uderstand

Confirmed but only when contrast enhacement is "Not set" or "Clip to MinMax". In all other cases I get correct values.
After looking into code I found that legend values are gathered from QgsContrastEnhancement object, so if contrast enhacement is "Not set" there are no values found and defaults used.

#9 Updated by Paolo Cavallini about 12 years ago

  • Target version changed from Version 1.7.4 to Version 1.8.0

#10 Updated by Paolo Cavallini over 11 years ago

  • Target version changed from Version 1.8.0 to Version 2.0.0

#11 Updated by Giovanni Manghi over 11 years ago

  • Resolution set to fixed
  • Status changed from Open to Closed

This has been fixed in master.

Also available in: Atom PDF