[GRASSLIST:4899] reversing cat order for d.legend ?

H. Bowman ihatejunkyabastards at yahoo.com
Thu Nov 7 07:33:21 EST 2002

Hello all,

I would like to display a legend box showing how elevation relates to map 
color for a raster DEM.

d.legend works, but the lowest elevations are at the top, and the mountain 
peak elevations are at at the bottom of the legend. Is there a way to 
reverse this? r.report displays smallest values first, so I suppose 
d.legend follows from that?

Trying to be sneaky and making the first corner not the top left, and the 
second corner above the first doesn't seem to do the right thing at all. 
It looks better if I make a horizontal legend, but that doesn't look quite 
right below to my tall, thin display.
Should I give up and just flip it in Gimp and add then re-add the text 
labels by hand?

Also with regards to d.legend, any suggestions for defining the bounds and 
output format of the text labels? lines= and thin= don't seem to make any 
difference (because floating point raster?), and outputting 6 digits 
beyond the decimal is a bit excessive for my application. I don't mind 
manually placing text, but I would like to have the bounds be nice whole 
numbers a bit larger than my range. I'd rather not introduce false data 
points to trick the range.

Should I be looking at printf("%.0f",foo) etc and a recompile...?
and modify the code to grab the range from my custom color table?


More information about the grass-user mailing list