[GRASS-dev] [GRASS GIS] #3221: r.cross output misses one category

#3221: r.cross output misses one category
-------------------------+-------------------------
Reporter: pvanbosgeo | Owner: grass-dev@…
     Type: defect | Status: new
Priority: normal | Milestone: 7.0.6
Component: Default | Version: unspecified
Keywords: | CPU: Unspecified
Platform: Unspecified |
-------------------------+-------------------------
I have two layers with 2 categories (1 and 2) each. When combined using
r.cross the output is a map with three categories according to the message
on the command line. Also, the map created has three colours.

Yet, there should be four categories, and there is indeed a fourth
category with value 0 (but without category label)

{{{
r.stats -l input=grevrobenvclust
0
1 category 1; category 2
2 category 2; category 1
3 category 2; category 2
* no data
}}}

This category 0 is the area where both layers have a value 1. See also the
attached screenshot.

So there are the problems that:

* only three categories are reported, while there are four in reality
* one (the first) category has no category label with the values of the
input maps
* the category 0 (without category label) is assigned the same colour as
category 3
* When running the tool to create interactively the colour table, colours
are only assigned to categories 1-3, so the category 0 should not have a
colour (see attached screenshot). Clicking the 'apply' button without
changing the categories, and the category 0 will indeed disappear from the
map.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221&gt;
GRASS GIS <https://grass.osgeo.org>

#3221: r.cross output misses one category
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: unspecified
Resolution: | Keywords:
       CPU: Unspecified | Platform: Unspecified
--------------------------+-------------------------
Changes (by pvanbosgeo):

* Attachment "screenshot.png" added.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221&gt;
GRASS GIS <https://grass.osgeo.org>

#3221: r.cross output misses one category
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Linux
--------------------------+-------------------------
Changes (by pvanbosgeo):

* platform: Unspecified => Linux
* version: unspecified => svn-trunk

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221#comment:1&gt;
GRASS GIS <https://grass.osgeo.org>

#3221: r.cross output misses one category
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.6
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Linux
--------------------------+-------------------------

Comment (by mlennert):

Replying to [ticket:3221 pvanbosgeo]:
> I have two layers with 2 categories (1 and 2) each. When combined using
r.cross the output is a map with three categories according to the message
on the command line. Also, the map created has three colours.
>
> Yet, there should be four categories, and there is indeed a fourth
category with value 0 (but without category label)
>
> {{{
> r.stats -l input=grevrobenvclust
> 0
> 1 category 1; category 2
> 2 category 2; category 1
> 3 category 2; category 2
> * no data
> }}}
>

I can confirm this with the NC dataset in grass73. Maybe some issue with
category value 0 ?:

{{{
r.cross -z input=landclass96@PERMANENT,geology_30m@PERMANENT output=test
r.category map=test@user1
0
1 category 1; CZlg
2 category 1; CZig
3 category 1; CZbg
4 category 1; CZve
5 category 1; CZam
6 category 1; CZg
7 category 1; CZam
8 category 1; CZbg
9 category 1; Km
10 category 1; CZam
11 category 2; CZfg
12 category 2; CZlg
13 category 2; CZig
14 category 2; CZbg
15 category 2; CZam
16 category 2; CZbg
17 category 2; Km
18 category 2; CZam
19 category 2; CZam
20 category 3; CZfg
21 category 3; CZlg
22 category 3; CZig
23 category 3; CZbg
24 category 3; CZve
25 category 3; CZam
26 category 3; CZg
27 category 3; CZam
28 category 3; CZbg
29 category 3; Km
30 category 4; CZfg
31 category 4; CZlg
32 category 4; CZig
33 category 4; CZbg
34 category 4; CZve
35 category 4; CZam
36 category 4; CZg
37 category 4; CZam
38 category 4; CZbg
39 category 4; Km
40 category 4; CZam
41 category 4; CZam
42 category 5; CZfg
43 category 5; CZlg
44 category 5; CZig
45 category 5; CZbg
46 category 5; CZve
47 category 5; CZam
48 category 5; CZg
49 category 5; CZam
50 category 5; CZbg
51 category 5; Km
52 category 5; CZam
53 category 5; CZam
54 category 6; CZfg
55 category 6; CZlg
56 category 6; CZig
57 category 6; CZbg
58 category 6; CZve
59 category 6; CZam
60 category 6; CZbg
61 category 6; Km
62 category 7; CZfg
63 category 7; CZig
}}}

With r.stats I get:

{{{
r.stats -cl test
0 15374
1 category 1; CZlg 5652
2 category 1; CZig 39828
3 category 1; CZbg 4230
4 category 1; CZve 248
5 category 1; CZam 9
6 category 1; CZg 19
7 category 1; CZam 156
8 category 1; CZbg 183
9 category 1; Km 29
10 category 1; CZam 15
11 category 2; CZfg 943
12 category 2; CZlg 178
13 category 2; CZig 83
14 category 2; CZbg 127
15 category 2; CZam 90
16 category 2; CZbg 169
17 category 2; Km 264
18 category 2; CZam 56
19 category 2; CZam 2
20 category 3; CZfg 9047
21 category 3; CZlg 5600
22 category 3; CZig 6037
23 category 3; CZbg 1342
24 category 3; CZve 24
25 category 3; CZam 102
26 category 3; CZg 3
27 category 3; CZam 338
28 category 3; CZbg 394
29 category 3; Km 37
30 category 4; CZfg 7744
31 category 4; CZlg 1088
32 category 4; CZig 1434
33 category 4; CZbg 2935
34 category 4; CZve 156
35 category 4; CZam 11
36 category 4; CZg 70
37 category 4; CZam 955
38 category 4; CZbg 411
39 category 4; Km 168
40 category 4; CZam 70
41 category 4; CZam 14
42 category 5; CZfg 43767
43 category 5; CZlg 9039
44 category 5; CZig 28336
45 category 5; CZbg 19434
46 category 5; CZve 1956
47 category 5; CZam 414
48 category 5; CZg 694
49 category 5; CZam 4900
50 category 5; CZbg 3770
51 category 5; Km 833
52 category 5; CZam 279
53 category 5; CZam 64
54 category 6; CZfg 3514
55 category 6; CZlg 492
56 category 6; CZig 159
57 category 6; CZbg 121
58 category 6; CZve 17
59 category 6; CZam 419
60 category 6; CZbg 18
61 category 6; Km 5
62 category 7; CZfg 64
63 category 7; CZig 120
* no data 950
}}}

and when running r.stats directly on the two input maps:

{{{
r.stats -lnc landclass96,geology_30m
1 217 CZfg 15374
1 262 CZlg 5652
1 270 CZig 39828
1 405 CZbg 4230
1 583 CZve 248
1 720 CZam 9
1 766 CZg 19
1 862 CZam 156
1 910 CZbg 183
1 921 Km 29
1 946 CZam 15
2 217 CZfg 943
2 262 CZlg 178
2 270 CZig 83
2 405 CZbg 127
2 862 CZam 90
2 910 CZbg 169
2 921 Km 264
2 946 CZam 56
2 948 CZam 2
3 217 CZfg 9047
3 262 CZlg 5600
3 270 CZig 6037
3 405 CZbg 1342
3 583 CZve 24
3 720 CZam 102
3 766 CZg 3
3 862 CZam 338
3 910 CZbg 394
3 921 Km 37
4 217 CZfg 7744
4 262 CZlg 1088
4 270 CZig 1434
4 405 CZbg 2935
4 583 CZve 156
4 720 CZam 11
4 766 CZg 70
4 862 CZam 955
4 910 CZbg 411
4 921 Km 168
4 946 CZam 70
4 948 CZam 14
5 217 CZfg 43767
5 262 CZlg 9039
5 270 CZig 28336
5 405 CZbg 19434
5 583 CZve 1956
5 720 CZam 414
5 766 CZg 694
5 862 CZam 4900
5 910 CZbg 3770
5 921 Km 833
5 946 CZam 279
5 948 CZam 64
6 217 CZfg 3514
6 262 CZlg 492
6 270 CZig 159
6 405 CZbg 121
6 583 CZve 17
6 862 CZam 419
6 910 CZbg 18
6 921 Km 5
7 217 CZfg 64
7 270 CZig 120
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221#comment:2&gt;
GRASS GIS <https://grass.osgeo.org>

#3221: r.cross output misses one category
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.7
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Linux
--------------------------+-------------------------

Comment (by martinl):

Still relevant?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221#comment:4&gt;
GRASS GIS <https://grass.osgeo.org>

#3221: r.cross output misses one category
--------------------------+-------------------------
  Reporter: pvanbosgeo | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.7
Component: Default | Version: svn-trunk
Resolution: | Keywords:
       CPU: Unspecified | Platform: Linux
--------------------------+-------------------------

Comment (by veroandreo):

IIUC, this was fixed in #72281.

I tested in relbranch and I get a category 0 which is the product of the 2
input maps:

{{{
r.cross -z input=landclass96@PERMANENT,geology_30m@PERMANENT output=test
r.category map=test
0 developed; CZfg
1 developed; CZlg
2 developed; CZig
3 developed; CZbg
...
}}}

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/3221#comment:5&gt;
GRASS GIS <https://grass.osgeo.org>