[GRASS5] 0 != no data

Michel Wurtz mw at teledetection.fr
Tue Jun 26 07:16:05 EDT 2001


Justin Hickey wrote:
>
> Interesting, but I think you may be thinking of instances where Grass
> interprets CELL files as unsigned 1 byte values (ie all values are in
> the range of 0 to 255). However, Grass cannot change the size of type
> CELL, so CELL files can only be 1 byte data if all CELL values are 1
> byte. In the file src/include/gis.h we have the following line:
> 
> typedef int CELL;
>

Hmmm... Does this mean that the "format" field in the header file
is not used ? (Cf progmangrass50, section 5.3.1).  I have also some
(uncompressed) raster files clearly in bytes (image size = row x column)

> Thus, all CELL values would be 1 byte if type int was 1 byte. Since most
> machines define int as 4 bytes, then I think what is happening is that
> whatever modules you were using interpreted CELL values as unsigned 1
> byte values, but the actual size would still be 4 bytes. Thus, the NULL
> value would still be 80000000.
> 
[...]
> So, if type int is a single byte, then cellNullPattern would be 80 in
> hex.
> 
> The critical assumption is that CELL will always be defined as a
> "signed" integer (of any size) so that the NULL value is the lowest
> number in the possible range of values. I think this is a safe
> assumption since most people would expect valid CELL data to include
> negative values. Of course, if it is unsigned, then my code will choose
> a value in the middle of the range, for example 128 for a 1 byte
> unsigned int, which is not an end point of the range of values.

This is the reason that make me worry about the changes : a classic sheme
is to use positive number for categories and 0 for "unknown" or NULL.
On the other hand, i have found that Grass null files are often bigger
than their raster counterpart.  Maybe just adding a field "null: value"
in the header file have been enough... this also take a value from the
range of possible values (which is only annoying for byte encoded raster),
but you can choose it (and even consider that the null value is 0 when
the field is missing, ensuring compatibility with grass4.0 rasters)

--
Michel WURTZ - DIG - Maison de la télédétection
               500, rue J.F. Breton
               34093 MONTPELLIER Cedex 5



More information about the grass-dev mailing list