[GRASS-dev] r.cross 0 output inconsistency

Hi devs,
I found a strange r.cross behaviour, the output includes a random 0 category without any label information. Here an example in the NC sample location:

g.version -rg
> version=7.0.0
> date=2015
> revision=00000
> build_date=2015-01-24
> build_platform=x86_64-unknown-linux-gnu
> libgis_revision=64007
> libgis_date="2015-01-08 20:08:36 +0100 (Thu, 08 Jan 2015) "

# set region so that all maps have non-NULL values
g.region n=224470 s=219020 w=633040 e=640160

r.cross basins,landuse,soils out=test__

r.mapcalc exp='test__0=if(test__==0)'
r.stats test__0 -c
> 0 335445
> 1 189

These 0 areas change when the region is changed or a mask is applied. The only correlation with the input data I could find was the fact that one of them always seems to have the category 1 in these areas. That seems like an inconsistent behaviour and annoying if you expect non-zero output or rely on the label information of the output.

Best regards,
Michel

On Wed, May 13, 2015 at 2:38 PM, Michel Wortmann
<wortmann@pik-potsdam.de> wrote:

Hi devs,
I found a strange r.cross behaviour, the output includes a random 0 category
without any label information. Here an example in the NC sample location:

So you used the nc_basic location, did you take the G7 version of it?

# set region so that all maps have non-NULL values
g.region n=224470 s=219020 w=633040 e=640160

--> this is missing the resolution setting, so it "inherits" it from
what whay you did before.

r.cross basins,landuse,soils out=test__

r.mapcalc exp='test__0=if(test__==0)'
r.stats test__0 -c

0 335445
1 189

I tested with the full NC dataset
basins -> basin_50K
landuse -> landuse96_28m
soils -> soilsID

GRASS 7.0.0svn (nc_spm_08_grass7): > g.region n=224470 s=219020
w=633040 e=640160 align=basin_50K -p
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: a=6378137 es=0.006694380022900787
north: 224470
south: 219020
west: 633040
east: 640160
nsres: 10
ewres: 10
rows: 545
cols: 712
cells: 388040

GRASS 7.0.0svn (nc_spm_08_grass7): > r.cross
basin_50K,landuse96_28m,soilsID out=test__
r.cross: STEP 1 ...
100%
r.cross: STEP 2 ...
r.cross: STEP 3 ...
100%
Creating support files for <test__>...
2507 categories

GRASS 7.0.0svn (nc_spm_08_grass7): > r.mapcalc "test__0 = if(test__==
0, 1, null() )"
100%

GRASS 7.0.0svn (nc_spm_08_grass7): > r.stats test__0 -c
100%
1 5
* 388035

I don't get these zeros. Please check which resolution you actually applied.

best,
Markus