[GRASS-dev] r.diversity.py for GRASS 7

Hi,

I just tried to install the r.diversity addon in GRASS 7, but it doesn’t seem to work. Are there any plans to port this in the near future to GRASS 7? I had a look myself, but my Python skills are too limited.

Rgds

Paulo

Hi Paulo,
(cc Luca)

On Sun, Jan 5, 2014 at 10:50 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:

Hi,

I just tried to install the r.diversity addon in GRASS 7, but it doesn't
seem to work. Are there any plans to port this in the near future to GRASS
7? I had a look myself, but my Python skills are too limited.

Done in r58619 (easy since it was already written in Python) and r58621.

You may try with g.extension to install and use it but I think it
needs a bit more finetuning (I didn't get the examples running yet,
but it will be rather easy for a Python programmer).

Markus

Hi Markus,

Thanks, I was able to install it. Running it gave me the error :

Traceback (most recent call last):
  File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 284, in <module>
    sys.exit(main())
  File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 139, in main
    checkAlpha(methods,alpha_value)
UnboundLocalError: local variable 'alpha_value' referenced
before assignment

After filling in an alpha value (1) it runs but I get the next error message (but the alpha value should be optional, right?):

ERROR: Cannot find configuration file </home/paulo/.grass7/r.li/conf_diversity_3.0>
[1.0]
All works are terminated

Indeed, in the given folder there is not such conf file.

Cheers,

Paulo

On Mon 06 Jan 2014 12:57:28 AM CET, Markus Neteler wrote:

Hi Paulo,
(cc Luca)

On Sun, Jan 5, 2014 at 10:50 PM, Paulo van Breugel
<p.vanbreugel@gmail.com> wrote:

Hi,

I just tried to install the r.diversity addon in GRASS 7, but it doesn't
seem to work. Are there any plans to port this in the near future to GRASS
7? I had a look myself, but my Python skills are too limited.

Done in r58619 (easy since it was already written in Python) and r58621.

You may try with g.extension to install and use it but I think it
needs a bit more finetuning (I didn't get the examples running yet,
but it will be rather easy for a Python programmer).

Markus

On 6 January 2014 11:13, Paulo van Breugel <p.vanbreugel@gmail.com> wrote:

Hi Markus,

Hi

Thanks, I was able to install it. Running it gave me the error :

Traceback (most recent call last):
File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 284, in <module>
   sys.exit(main())
File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 139, in main
   checkAlpha(methods,alpha_value)
UnboundLocalError: local variable 'alpha_value' referenced
before assignment

thanks, you discovered a bug :wink:
Fixed

After filling in an alpha value (1) it runs but I get the next error message
(but the alpha value should be optional, right?):

it is not optional if you use the renyi and by default all methods are
used (before it was not specify, now yes :wink:

ERROR: Cannot find configuration file
</home/paulo/.grass7/r.li/conf_diversity_3.0>
[1.0]
All works are terminated

Indeed, in the given folder there is not such conf file.

yes, because the directory change from grass6 to grass7, fixed.

Now it should work, please try 58632

Cheers,

Paulo

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

Hi Luca

Great, thanks!

I just tried to run the function, but initially got the error:

ERROR: Reading raster map <ANN_MOD14A2_2002_L1_count@Fire> request for row 68 is outside region

This was with a region smalller than the input map. After setting the region to cover the whole map, the function ran without problems. Which brings me to the question, does the function (or the underlying r.li) not respect the region settings or is this a bug?

Cheers,

Paulo

On Tue 07 Jan 2014 01:39:47 AM CET, Luca Delucchi wrote:

On 6 January 2014 11:13, Paulo van Breugel <p.vanbreugel@gmail.com> wrote:

Hi Markus,

Hi

Thanks, I was able to install it. Running it gave me the error :

Traceback (most recent call last):
  File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 284, in <module>
    sys.exit(main())
  File "/home/paulo/.grass7/addons/scripts/r.diversity",
line 139, in main
    checkAlpha(methods,alpha_value)
UnboundLocalError: local variable 'alpha_value' referenced
before assignment

thanks, you discovered a bug :wink:
Fixed

After filling in an alpha value (1) it runs but I get the next error message
(but the alpha value should be optional, right?):

it is not optional if you use the renyi and by default all methods are
used (before it was not specify, now yes :wink:

ERROR: Cannot find configuration file
</home/paulo/.grass7/r.li/conf_diversity_3.0>
[1.0]
All works are terminated

Indeed, in the given folder there is not such conf file.

yes, because the directory change from grass6 to grass7, fixed.

Now it should work, please try 58632

Cheers,

Paulo

On 7 January 2014 07:35, Paulo van Breugel <p.vanbreugel@gmail.com> wrote:

Hi Luca

Hi Paulo

Great, thanks!

I just tried to run the function, but initially got the error:

ERROR: Reading raster map <ANN_MOD14A2_2002_L1_count@Fire> request for row
68 is outside region

This was with a region smalller than the input map. After setting the region
to cover the whole map, the function ran without problems. Which brings me
to the question, does the function (or the underlying r.li) not respect the
region settings or is this a bug?

I think this is a bug of r.li modules in GRASS7.
I try to create the same configuration file with GRASS7 and GRASS6 and
they are identical but in GRASS6 I don't obtain any error instead in
GRASS7 I obtain your same error.

I'm going to open a ticket in the next hours/days.

Thanks

Cheers,

Paulo

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

OK, thanks

On Wed 08 Jan 2014 11:41:56 AM CET, Luca Delucchi wrote:

On 7 January 2014 07:35, Paulo van Breugel <p.vanbreugel@gmail.com> wrote:

Hi Luca

Hi Paulo

Great, thanks!

I just tried to run the function, but initially got the error:

ERROR: Reading raster map <ANN_MOD14A2_2002_L1_count@Fire> request for row
68 is outside region

This was with a region smalller than the input map. After setting the region
to cover the whole map, the function ran without problems. Which brings me
to the question, does the function (or the underlying r.li) not respect the
region settings or is this a bug?

I think this is a bug of r.li modules in GRASS7.
I try to create the same configuration file with GRASS7 and GRASS6 and
they are identical but in GRASS6 I don't obtain any error instead in
GRASS7 I obtain your same error.

I'm going to open a ticket in the next hours/days.

Thanks

Cheers,

Paulo

On 8 January 2014 11:41, Luca Delucchi <lucadeluge@gmail.com> wrote:

Hi Paulo

Hi Devs,

I think this is a bug of r.li modules in GRASS7.
I try to create the same configuration file with GRASS7 and GRASS6 and
they are identical but in GRASS6 I don't obtain any error instead in
GRASS7 I obtain your same error.

I was wrong, also GRASS6 has the same problem (maybe in GRASS6 is
worst because it continue to print the message for all row outside
region)
I open a new thread/ticket

I'm going to open a ticket in the next hours/days.

Thanks

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org

On Wed, Jan 8, 2014 at 11:41 AM, Luca Delucchi <lucadeluge@gmail.com> wrote:
...

I think this is a bug of r.li modules in GRASS7.
I try to create the same configuration file with GRASS7 and GRASS6 and

...

I'm going to open a ticket in the next hours/days.

Please try first the patch

http://trac.osgeo.org/grass/ticket/2024
r_li_bug_2024.diff (15.9 KB) - added by rashadkm 2 weeks ago.r.li.* fixes

Markus

On 8 January 2014 15:46, Markus Neteler <neteler@osgeo.org> wrote:

Please try first the patch

test it....

http://trac.osgeo.org/grass/ticket/2024
r_li_bug_2024.diff (15.9 KB) - added by rashadkm 2 weeks ago.r.li.* fixes

the patch probably fix other problems :wink:

Markus

--
ciao
Luca

http://gis.cri.fmach.it/delucchi/
www.lucadelu.org