[GRASS-user] r.cross doesn't work correctly.

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1 to 1)

eg

r.category map=myinput@in_data
0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have there category 1; category 1)
the problem is that I have to iterate on 700 cases and I wont check and correct manually.

could you fix it?
thanks
Grazia

* Gra <graziaz@gmail.com> [2018-02-26 11:19:33 +0100]:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn't work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn't list the first combination (eg 1 to
1)

eg
r.category map=myinput@in_data
0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality *the first combination exists (0 is empty but I should have
there category 1; category 1)*
the problem is that I have to iterate on 700 cases and I wont check and
correct manually.

could you fix it?
thanks
Grazia

See also:

* https://lists.osgeo.org/pipermail/grass-dev/2016-June/080972.html?lipi=urn%3Ali%3Apage%3Ad_flagship3_messaging%3BZjdpjz2OQzmL6MmE4M8uTQ%3D%3D
* https://trac.osgeo.org/grass/ticket/3080?lipi=urn%3Ali%3Apage%3Ad_flagship3_messaging%3BZjdpjz2OQzmL6MmE4M8uTQ%3D%3D
* https://lists.osgeo.org/pipermail/grass-dev/2017-September/086090.html

Nikos

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1 to 1)

eg
r.category map=myinput@in_data
0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have there category 1; category 1)
the problem is that I have to iterate on 700 cases and I wont check and correct manually.

could you fix it?

Please try trunk r72281

Markus M

thanks
Grazia


grass-user mailing list
grass-user@lists.osgeo.org
https://lists.osgeo.org/mailman/listinfo/grass-user

* Markus Metz <markus.metz.giswork@gmail.com> [2018-02-26 13:01:35 +0100]:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn't work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn't list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

I get now (compared to what I've posted in the other post):

0 CZfg; category 1
1 CZfg; category 2
2 CZbg; category 1
3 CZbg; category 2
4 CZg; category 1

What about the -z flag, though?

r.category geology_Test
217 CZfg
405 CZbg
766 CZg

r.category basins_0_12
0 0
12 Twelve

r.cross input=geology_Test,basins_0_12 out=cross_Test_6
r.cross input=geology_Test,basins_0_12 out=cross_Test_7 -z

r.category cross_Test_6
0 CZfg; 0
1 CZfg; Twelve
2 CZbg; 0
3 CZbg; Twelve
4 CZg; 0

and

r.category cross_Test_7
0 CZfg; 0
1 CZfg; Twelve
2 CZbg; 0
3 CZbg; Twelve
4 CZg; 0

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

By the way, it should be: "In the following example..." and not "In the
example given above...".

Nikos

Markus M

thanks
Grazia

Hi
I tried also the -z flag.

I attach the result and the two inputs

Thanks

Grazia

(attachments)

result.pack (98.7 KB)
os.pack (65.3 KB)
RPnr.pack (78.8 KB)

···

2018-02-26 13:31 GMT+01:00 Nikos Alexandris <nik@nikosalexandris.net>:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

I get now (compared to what I’ve posted in the other post):

0 CZfg; category 1
1 CZfg; category 2
2 CZbg; category 1
3 CZbg; category 2
4 CZg; category 1

What about the -z flag, though?

r.category geology_Test
217 CZfg
405 CZbg
766 CZg

r.category basins_0_12
0 0
12 Twelve

r.cross input=geology_Test,basins_0_12 out=cross_Test_6
r.cross input=geology_Test,basins_0_12 out=cross_Test_7 -z

r.category cross_Test_6
0 CZfg; 0
1 CZfg; Twelve
2 CZbg; 0
3 CZbg; Twelve
4 CZg; 0

and

r.category cross_Test_7
0 CZfg; 0
1 CZfg; Twelve
2 CZbg; 0
3 CZbg; Twelve
4 CZg; 0

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

By the way, it should be: “In the following example…” and not “In the
example given above…”.

Nikos

Markus M

thanks
Grazia

On Mon, Feb 26, 2018 at 1:31 PM, Nikos Alexandris <nik@nikosalexandris.net> wrote:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

What about the -z flag, though?

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

The -z flag does not behave as explained in the manual. It comes from the old days when there was no NULL encoding in GRASS, and zero was used as nodata. Now the -z flag means that with the -z flag, NULL values are not crossed, not that zero data are not crossed. This has been introduced in 2013 with r55276. The results of r.cross without the -z flag might look strange if any of the input maps contains NULL cells.

Markus M

By the way, it should be: “In the following example…” and not “In the
example given above…”.

Nikos

Markus M

thanks
Grazia

* Markus Metz <markus.metz.giswork@gmail.com> [2018-02-26 14:38:08 +0100]:

On Mon, Feb 26, 2018 at 1:31 PM, Nikos Alexandris <nik@nikosalexandris.net>
wrote:

* Markus Metz <markus.metz.giswork@gmail.com> [2018-02-26 13:01:35 +0100]:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn't work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn't list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

What about the -z flag, though?

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

The -z flag does not behave as explained in the manual. It comes from the
old days when there was no NULL encoding in GRASS, and zero was used as
nodata. Now the -z flag means that with the -z flag, NULL values are not
crossed, not that zero data are not crossed. This has been introduced in
2013 with r55276. The results of r.cross without the -z flag might look
strange if any of the input maps contains NULL cells.

Markus M

Maybe renaming to -n (in future versions) ?

Nikos

By the way, it should be: "In the following example..." and not "In the
example given above...".

Nikos

Markus M

thanks
Grazia

--
Nikos Alexandris | Remote Sensing & Geomatics
GPG Key Fingerprint 6F9D4506F3CA28380974D31A9053534B693C4FB3

On Mon, Feb 26, 2018 at 2:38 PM, Markus Metz <markus.metz.giswork@gmail.com> wrote:

On Mon, Feb 26, 2018 at 1:31 PM, Nikos Alexandris <nik@nikosalexandris.net> wrote:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

What about the -z flag, though?

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

The -z flag does not behave as explained in the manual. It comes from the old days when there was no NULL encoding in GRASS, and zero was used as nodata. Now the -z flag means that with the -z flag, NULL values are not crossed, not that zero data are not crossed. This has been introduced in 2013 with r55276. The results of r.cross without the -z flag might look strange if any of the input maps contains NULL cells.

The manual has been updated in r72285 to explain the current (as of r55276) behaviour with regard to the -z flag. Additionally, NULL values get now the label “NULL”.

Markus M

By the way, it should be: “In the following example…” and not “In the
example given above…”.

Nikos

Markus M

thanks
Grazia

ok thanks
but in my case the combination existed (there was not a null value problem), the command skipped the first combination (category 1 with category 1).

Grazia

···

2018-02-26 18:42 GMT+01:00 Markus Metz <markus.metz.giswork@gmail.com>:

On Mon, Feb 26, 2018 at 2:38 PM, Markus Metz <markus.metz.giswork@gmail.com> wrote:

On Mon, Feb 26, 2018 at 1:31 PM, Nikos Alexandris <nik@nikosalexandris.net> wrote:

On Mon, Feb 26, 2018 at 11:19 AM, Gra <graziaz@gmail.com> wrote:

Dear community

I use r.cross to combine and then reclassify a set of indicators.

I realised that r.cross doesn’t work correctly.

I have two inputs maps with values from 1 to 3 each.

the problem is that r.category doesn’t list the first combination (eg 1

to 1)

eg
r.category map=myinput@in_data

0
1 category 1; category 2
2 category 1; category 3
3 category 2; category 1
4 category 2; category 2
5 category 2; category 3
6 category 3; category 1
7 category 3; category 2
8 category 3; category 3

in reality the first combination exists (0 is empty but I should have

there category 1; category 1)

the problem is that I have to iterate on 700 cases and I wont check and

correct manually.

could you fix it?

Please try trunk r72281

Works for me, thank you.

What about the -z flag, though?

The manual reads:

With the -z flag zero data values are not crossed. This means that if a
zero category value occurs in any input data layer, the combination is
assigned to category zero in the resulting map layer, even if other data
layers contain non-zero data. In the example given above, use of the -z
option would cause 3 categories to be generated instead of 5.

The -z flag does not behave as explained in the manual. It comes from the old days when there was no NULL encoding in GRASS, and zero was used as nodata. Now the -z flag means that with the -z flag, NULL values are not crossed, not that zero data are not crossed. This has been introduced in 2013 with r55276. The results of r.cross without the -z flag might look strange if any of the input maps contains NULL cells.

The manual has been updated in r72285 to explain the current (as of r55276) behaviour with regard to the -z flag. Additionally, NULL values get now the label “NULL”.

Markus M

By the way, it should be: “In the following example…” and not “In the
example given above…”.

Nikos

Markus M

thanks
Grazia