[GRASS5] [bug #2333] (grass) r.colors: 0.0%, 100.0% doesn't match 'r.info -r'

Glynn Clements glynn.clements at virgin.net
Mon Feb 23 21:13:04 EST 2004


Request Tracker wrote:

> Subject: r.colors: 0.0%, 100.0% doesn't match 'r.info -r'
> 
> Platform: GNU/Linux/i386
> grass obtained from: Mirror of Trento site
> grass binary for platform: Compiled from Sources
> GRASS Version: 5.3-cvs feb 2004
> 
> setting r.colors' by percentage value isn't correct, making boundary
> values show up on the map as patches of no colour.
> 
> 
> e.g.,
> 
> G > r.info -r temperature_map
> min=10.812000
> max=13.251400
> 
> G > r.colors temperature_map col=rules << EOF
> > 0.0% blue
> > 33.333% cyan
> > 66.666% yellow
> > 100.0% red
> > EOF
> WARNING: Your color rules do not cover the whole range of data!
> Color table for [temperature_map] set to rules
> 
> G > cat "$MAPSET"/colr/temperature_map
> % 10.824197023703662878801878832746 13.263596965230153301718019065447
> 10.824197023703662878801878832746:0:0:255 11.6365172042:0:255:255
> 11.6365172042:0:255:255 12.4488373848:255:255:0
> 12.4488373848:255:255:0 13.263596965230153301718019065447:255:0:0
> 
> 
> 
> 10.824197... colr > 10.812000 map.
> here maximum fails cleanly..
> 
> ?

src/raster/r.colors/cmd/rules.c, lines 190 and 247:

	    *val = min + ((double)max-(double)min)*(n+0.5)/100.0;

It adds 0.5% to the specified value. In 4.3, the corresponding lines
look like this:

	    *cat = min + ((double)max-(double)min)*n/100.0 + .5;

where *cat, min, max and n are all integers.

Simply removing the +0.5 would result in a significant improvement,
but there could still be residual problems with the actual min/max
values due to rounding errors.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list