[GRASS5] [bug #1956] (grass) r.reclass: re-reclass categories off by one/many

Request Tracker grass-bugs at intevation.de
Thu Jun 19 19:10:18 EDT 2003

this bug's URL: http://intevation.de/rt/webrt?serial_num=1956

Subject: r.reclass: re-reclass categories off by one/many 

Platform: GNU/Linux/i386
grass binary for platform: Downloaded precompiled Binaries
GRASS Version: GRASS 5.0.0pre4

r.reclass produces a shift in assigned categories when reclassifying raster layers which are themselves products of a reclassification (re-reclass). this shift is easily visible when comparing the resulting files in MAPSET/cellhd. it appears to me to be a small mistake in the compose() function in src/raster/r.reclass/cmd/reclass.c which is only called for re-reclass. 
if the lowest assigned category number is not 0, the way the category table is filled will be inadeqate (i.e. array is not filled starting from position 0), as G_put_reclass() will read that array starting from 0 later on. 
my C isn't so hot, but the following change made it work for me:

in src/raster/r.reclass/cmd/reclass.c:
<start diff output>
< 	new->table[i] = k;
> 	new->table[i - new->min] = k;

this also worked for the interactive mode (i expect it calls the same function).

maybe this solution is a little too simple, i don't claim to have fully (or even partially) understood the design behind the structs involved. 
what mystifies me is why i haven't seen anything in the bug reports about this. the problem surfaced in a grass course at the university of freiburg using the spearfish data set. the task was to reclassify the "texture" raster layer, which is a reclassification of the "soils" raster layer. the results where quite obviously weird - i would have thought this might have happened elsewhere. my search of the bug lists, google groups etc didn't produce any hits, though. 
anyway, HTH, over to you :)

Caspar Hasenclever

-------------------------------------------- Managed by Request Tracker

More information about the grass-dev mailing list