[GRASS5] FCELL color problem

Glynn Clements glynn.clements at virgin.net
Fri Mar 1 17:20:11 EST 2002


Markus Neteler wrote:

> today my colleage Lorenzo Potrich discovered a color
> problem with FCELL data (INT and DCELL are o.k.).
> 
> The problem is a different behaviour between d.rast
> and d.his. When overlaying FCELL raster polygons without own
> color table (maybe also with, not tried) to a shade
> map, one polgygon *disappears*.
>  
> This works o.k. for INT and DCELL. Maybe someone else
> can try (and hopefully fix, I assume a color index problem).

Actually, it doesn't appear to be FCELL vs DCELL, but due to the fact
that the FCELL map has a range of 1.0-2.5 while the DCELL map has a
range of 0.0-3.0.

The problem is that G_get_c_raster_row() is rounding the FCELL value
to the nearest integer. For the red polygon, the value is being
rounded from 2.5 to 3, which is beyond the end of the colour table.

The obvious fix is not to coerce the data to CELL type. This seems to
be a situation where it initially appeared that the program didn't
need to be changed with the introduction of FP support, but it turns
out not to be so.

I've changed d.his to use G_get_raster_row_colors(), which combines
G_get_raster_row() with G_lookup_raster_colors(), using the map's
native type (CELL/FCELL/DCELL) for the intermediate buffer.

This also fixes the problem with d.his changing the colours of the
DCELL version.

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



More information about the grass-dev mailing list