[GRASS5] Re: [GRASSLIST:5474] r.clump seems not to clump reclassed map
Glynn Clements
glynn.clements at virgin.net
Wed Feb 5 20:55:03 EST 2003
[CC'd to developers' list.]
Aldo Clerici wrote:
> Hi GRASSusers,
> it seems that r.clump doesn't clump a reclassed map derived from a
> previously clumped map.
>
> Here an example (with spearfish data):
>
> r.clump input=geology output=geology.dump
> (422 clumps. Correct)
> r.reclass input=geology.clump output=geology.clump.rec
> > 50 200 = 1
> end
> (the map geology.clump.rec contains 2 groups of cells with category 1.
> Correct)
> r.clump input=geology.clump.rec output=geology.final
> (geology.final contains 11 clumps instead of 2. Not correct)
>
> Note that:
> 1) r.clump works well on a new map obtained from the reclassed map with
> r.resample.
> 2) With GRASS4.3 the above procedure works well. The geology.final map
> contains 2 clumps as aspected.
>
> Anything wrong in version 5 ?
Yes. I've tracked down the problem to the handling of reclass maps,
and, AFAICT, it's been there since the null-value support was added.
For now, you can work around the problem by explicitly telling
r.reclass to set all other categories to zero, i.e.:
r.reclass input=geology.clump output=geology.clump.rec
> 50 200 = 1
> * = 0
end
[The rest of the message is intended for the developers.]
The problem is that any categories which are outside of the range of
the reclass table (i.e. below 50 or above 200) are set to zero, while
undefined categories within the range of the reclass table (i.e.
between 51 and 199) are set to null (-2147483648).
Looking at do_reclass_int() (src/libes/gis/get_row.c, line 154), there
are three ways in which a null value can occur:
1. The input cell is null.
2. The input cell falls outside of the range of the reclass table.
3. The corresponding entry in the reclass table is null.
If the null_is_zero flag is set[1], case 2 results in a zero instead of a
null; however, the other two cases both result in a null.
[1] G_get_map_row[_nomask] are supposed to return zeros, while
G_get[_c]_raster_row[_nomask] return nulls.
The fix needs to go into 5.0.2.
--
Glynn Clements <glynn.clements at virgin.net>
More information about the grass-dev
mailing list