[GRASS5] FCELL color problem

Hi,

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).

A test location is here (Italian Gauss-Boaga):
http://mpa.itc.it/markus/tmp/colorproblem_location_f_dcell.tar.gz
(2.2MB)

containing a test script:

sh colorproblem/PERMANENT/testcase.sh

Thanks for help,

Markus

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@virgin.net>

On Fri, Mar 01, 2002 at 10:20:11PM +0000, Glynn Clements wrote:

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.

Sorry for this confusion, I tried to replicate a portion from
our database.

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.

Now it is all well. Thanks for fixing it!

Markus