[GRASS5] Opinion wanted - null data

Forwarded to the developers list.

On Tue, 3 Jul 2001, Justin Hickey wrote:

As you know, I have been looking at the issue of removing the feature
of "0 is no data", and the situation is currently at a point where
I'm not sure what is the best thing to do.

Justin,

  I'll vote again to have zero represent data and no data (or unknown
values) be represented by NULL.

2. Make the change and prolong the release by the amount of time for
   me to get back on-line and for coding and testing

3. Another developer volunteers to make the changes and the release
   is delayed for only a minimum amount of time (coding and testing)

  Either, or.

Good luck with the move,

Rich

Dr. Richard B. Shepard, President

                       Applied Ecosystem Services, Inc. (TM)
            2404 SW 22nd Street | Troutdale, OR 97060-1247 | U.S.A.
+ 1 503-667-4517 (voice) | + 1 503-667-8863 (fax) |
rshepard@appl-ecosys.com
                 Making environmentally-responsible mining happen.

Well, after reading a lot of mail and a little thinking, I propose
the following rules and implementation. Any remarks are welcome.

Add a field in raster's header files, "null:"
The values can be

null: No There is no null value in the raster file (faster)
null: NaN Null value is ISO Not_a_Number (for FCELL or DCELL)
null: <integer> Null value is represented by <integer> in the raster
                  (for 1, 2, 3 or 4 bytes integer raster files)
null: file=xxx where xxx is another raster file where 0 means null
                  (acts like Grass MASK) - should be an exception.

For old files (no "null:" field), use a Grass environment variable,
like GRASSNULLVALUE, which contains 0 or No (I think there is no
other alternative for pré-5.0 rasters)

Add the command r.null for creating/modifying null values :
the usage should be

    r.null raster=xxx value=No (or value=NaN, or value=<integer>)
or (exclusive use of value and mask)
    r.null raster=xxx mask=yyy
where xxx and yyy are raster files.

This should cover all cases. Using a "classic" raster file for null
means that this file can be compressed, unlike the actual "null file".
It means also that you can easely create or modify it, because every
raster functions work with it.

The only problem I see is when a command uses two (or more) files as
input file (like r.mapcalc). If the output is a CELL file, there is
no mean to find a correct "null value", so we must create a mask (a
raster file) and give him a name. I propose to use the generator for
uniques file names and use .nul as extension (like "12345678.nul")

A further enhancement may be a command to automatically replace the
file generated by a value not in the range of the raster values (a
first approach may use r.hist to find it...)

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