[GRASS-user] r.reclass null values

Hi,

I want to use r.cost to calculate accessibility surfaces based on an existing road network. In my cost surface, I want to associate a speed limit = 6kmh to every cell outside the network, which involves reclassifying all NULL values to 6. However. <r.reclass> doesn’t allow me to reclass the nulls. The following message appears:

WARNING: can’t have null on the left-hand side of the rule
illegal reclass rule. ignored

Any clues on how to do this? I couldn’t find any offer function which would do the trick.

Apologize if this is a “too simple” kind of question…
Thanks in advance,
António

António Rodrigues wrote:

I want to use r.cost to calculate accessibility surfaces based on an
existing road network. In my cost surface, I want to associate a speed
limit = 6kmh to every cell outside the network, which involves
reclassifying all NULL values to 6. However. <r.reclass> doesn't allow
me to reclass the nulls. The following message appears:

WARNING: can't have null on the left-hand side of the rule
illegal reclass rule. ignored

Any clues on how to do this? I couldn't find any offer function which
would do the trick.

Replace null with a specific value. Either use r.null[1] to modify the
existing map or r.mapcalc[2] to create a new map.

[1] E.g.: r.null map=oldmap null=6
[2] E.g.: r.mapcalc newmap = if(isnull(oldmap),6,oldmap)

A desire to reclass null normally indicates a misunderstanding of the
purpose of null. Null doesn't represent a distinct value, disjoint
from any other values which may occur. It represents an "no data" or
"unknown", a value which may or may not be equal to any given value.

E.g. in r.mapcalc, if x and y are both null, "x == y" and "x != y"
will both be null. If x is unknown and y is unknown, then whether x is
equal to y is also unknown. Similarly, if only one of x and y are
null, "x == y" and "x != y" will both be null; if one is unknown,
whether or not it is equal to some known value is unknown.

[This is why you have to use "isnull(x)" rather than "x == null()" to
test for null, as the latter will always evaluate to null.]

--
Glynn Clements <glynn@gclements.plus.com>