Open NikosAlexandris opened 3 years ago
Hi Nikos,
d.legend's -d flag is based on the code from d.histogram, so in theory both should give the same output. Moreover both run 'r.stats' in the background to generate the step class data. Does r.stats give the expected output?
My intention was that the -d flag should respect the current computational region.
( Hamish, nice to read you 😄 . I've been windmilled with other works (no GRASS GIS at the moment :-/), so I don't even remember the details anymore. Hopefully someone else can pick this up and help. Cheers! )
Nice to hear from you too. :-) I can have a look at this at some point, you left enough details to follow it up. One thing I'm currently trying to debug is some weirdness around the region resetting itself as part of the display module internal run-twice design. Which is to say if r.stats output looks ok but d.histogram &/or d.legend -d don't, a good check will be to see if this works properly in GRASS 6 but not in GRASS 7+. If so then we can look for a fix in the display mechanism. Might also test direct rendering vs. d.mon output to see if that makes a difference.
Describe the bug The histogram added via
-d
usingd.legend
, on top of the legend of a raster map, does not correspond to the raster values of the map in the current region.d.histogram
, however, correctly plots the distribution of values of the same raster map in the current region. I am unsure if this is a proble withd.legend
or related to the NULL file of the raster map.Expected behavior
d.legend -d
should create a histogram that matched the range of the distribution of a raster map's values inside the current computatinal region.To Reproduce In the following Location
set the region
and plot the legend of a MODIS product
So far good. Next, zoom in 'Freiburg'
and re-plot
The histogram is obviously (when looking at the map itself) wrong. Some meta:
and the map itself with values and the legend from the previous
d.legend
command:Tracking back the map's history:
and the original map
Obviously, it is not an external (
r.external
) nor a reclassified (r.reclass
) map. Before the scaling applied viar.mapcalc
on the original map, I did re-set0
values to become NULL (in a for loop for all maps of the series, including the raster map in question)Create/reset the null file for this raster map
and updating the histogram/range
This seems to have fixed the histogram, yet the range isn't the one we'd expect
0 is added back:
Anyhow, playing with
r.support
andr.null
I seem to come back to the same legend-problem when zoomed infreiburg
.I wonder if
d.legend -d
does not read the range of raster values of a map in the current region. Is the function Rast_read_fp_range() the one in question here, used here https://github.com/OSGeo/grass/blob/53eda832018485b0d02f94755c8cca9c499c528d/display/d.legend/histogram.c#L51?r.describe
with its-d
flag, does https://github.com/OSGeo/grass/blob/53eda832018485b0d02f94755c8cca9c499c528d/raster/r.describe/describe.c#L42-L44System description (please complete the following information):
GRASS GIS version