[GRASS-user] r.width.funct in correct version

I have found a discussion about r.width.funct in this list, but I am not sure about the meaning of the final comment in order to solve the problem.

Discussion is in this link
[https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html](https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html)

Bartolomei Chris and Markus Neteler says that it is already fixed.


I am trying to understand their comments.  I have exactly the same problem.  r.width.fucnt is not working.

What I did: 

- I have Linux Mint 19.1 Cinnamon, based on Ubuntu Bionic.
- Installed standard Grass 7.4.0 from Ubuntu repositories.

- Applied r.width.funct and failed.
- Removed this version and added new repository, recomended by [https://grass.osgeo.org/news/78/15/GRASS-GIS-7-4-2-released](https://grass.osgeo.org/news/78/15/GRASS-GIS-7-4-2-released)
- System got updated and new version came to linux.
- Installed  Grass 7.6.0 (new stable) from ppa:ubuntugis/ubuntugis-unstable
- Problem remains the same.
- Reinstalled  r.width.funct and failed.
- Replaced script in  r.width.funct for the one presented in this tread ([https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html](https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html)) and failed. 
I would like to keep the original standard repositories in order to let administrative maintenance tasks as simple as possible.

Did I missed something to solve the problem?

Prof. Juan Ygnacio López Hernández Ing. MSc. PhD.
Universidad de Los Andes
Escuela de Ingeniería Forestal
Mérida, Venezuela.
Tel. ++58 426 3185690

* Juan Lopez <cubarro@gmail.com> [2019-02-20 06:20:48 -0400]:

I have found a discussion about r.width.funct in this list, but I am
not sure about the meaning of the final comment in order to solve the
problem.

Discussion is in this link

https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html

Bartolomei Chris and Markus Neteler says that it is already fixed.

I am trying to understand their comments. I have exactly the same
problem. r.width.fucnt is not working.

What I did:

  - I have Linux Mint 19.1 Cinnamon, based on Ubuntu Bionic.
  - Installed standard Grass 7.4.0 from Ubuntu repositories.
  - Applied r.width.funct and failed.
  - Removed this version and added new repository, recomended by
https://grass.osgeo.org/news/78/15/GRASS-GIS-7-4-2-released
  - System got updated and new version came to linux.
  - Installed Grass 7.6.0 (new stable) from ppa:ubuntugis/ubuntugis-unstable
  - Problem remains the same.
  - Reinstalled r.width.funct and failed.
  - Replaced script in r.width.funct for the one presented in this
tread (https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html)
and failed.

I would like to keep the original standard repositories in order to
let administrative maintenance tasks as simple as possible.

Did I missed something to solve the problem?

Installation via g.extension fails here too:

→ g.version -r
GRASS 7.7.svn (2019)
libgis Revision: 73998
libgis Date: 2019-01-22 12:04:06 +0100 (Tue, 22 Jan 2019)

and

→ g.extension r.width.funct
Fetching <r.width.funct> from GRASS GIS Addons repository (be patient)...
Compiling...
Traceback (most recent call last):
  File "/tmp/grass7-nik-25324/tmpnmZ2V7/r.width.funct/scripts/r.width.funct", line 45, in <module>
    import matplotlib #required by windows
ImportError: No module named matplotlib
make: *** [/osgeo/grasstrunk/dist.x86_64-pc-linux-gnu/include/Make/Html.make:14: r.width.funct.tmp.html] Error 1
ERROR: Compilation failed, sorry. Please check above error messages.

Nikos

I am falling into this error because I am trying to upgrade the whole OS from 18 to 19 including qgis from 2.18 to 3.
But it is not a simple task.
Previously, r.width.funct was working just fine.

Regards

···

Prof. Juan Ygnacio López Hernández Ing. MSc. PhD.
Universidad de Los Andes
Escuela de Ingeniería Forestal
Mérida, Venezuela.
Tel. ++58 426 3185690

Hi,

here it is installed without issues both in grass76 and development version. Do you have matplotlib installed? AFAIU, that’s what the error is saying.

cheers,
Vero

El mié., 20 feb. 2019 a las 12:42, Juan Lopez (<cubarro@gmail.com>) escribió:

I am falling into this error because I am trying to upgrade the whole OS from 18 to 19 including qgis from 2.18 to 3.
But it is not a simple task.
Previously, r.width.funct was working just fine.

Regards

On Wed, Feb 20, 2019 at 7:22 AM Nikos Alexandris <nik@nikosalexandris.net> wrote:

I have found a discussion about r.width.funct in this list, but I am
not sure about the meaning of the final comment in order to solve the
problem.

Discussion is in this link

https://www.mail-archive.com/grass-user@lists.osgeo.org/msg37141.html

Bartolomei Chris and Markus Neteler says that it is already fixed.

I am trying to understand their comments. I have exactly the same
problem. r.width.fucnt is not working.

What I did:

I would like to keep the original standard repositories in order to
let administrative maintenance tasks as simple as possible.

Did I missed something to solve the problem?

Installation via g.extension fails here too:

→ g.version -r
GRASS 7.7.svn (2019)
libgis Revision: 73998
libgis Date: 2019-01-22 12:04:06 +0100 (Tue, 22 Jan 2019)

and

→ g.extension r.width.funct
Fetching <r.width.funct> from GRASS GIS Addons repository (be patient)...
Compiling...
Traceback (most recent call last):
File "/tmp/grass7-nik-25324/tmpnmZ2V7/r.width.funct/scripts/r.width.funct", line 45, in <module>
import matplotlib #required by windows
ImportError: No module named matplotlib
make: *** [/osgeo/grasstrunk/dist.x86_64-pc-linux-gnu/include/Make/Html.make:14: r.width.funct.tmp.html] Error 1
ERROR: Compilation failed, sorry. Please check above error messages.

Nikos

Prof. Juan Ygnacio López Hernández Ing. MSc. PhD.
Universidad de Los Andes
Escuela de Ingeniería Forestal
Mérida, Venezuela.
Tel. ++58 426 3185690


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

Hola Juan,

El mié., 20 feb. 2019 12:52, Juan Lopez <cubarro@gmail.com> escribió:

Dear Veronica.
I am agree with you. Maybe Nikos needs maplotlib, but I get allways
the same error. Here is a copy of my terminal messages:

Traceback (most recent call last):
File “/home/jefe/.grass7/addons/scripts/r.width.funct”,
line 135, in
sys.exit(main())
File “/home/jefe/.grass7/addons/scripts/r.width.funct”,
line 84, in main
prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
File “/home/jefe/.grass7/addons/scripts/r.width.funct”,
line 128, in findint
z1, z2, f1, f2 = kl[int(Xf[0])][0], kl[int(Xf[0]-1)][0],
kl[int(Xf[0])][1], kl[int(Xf[0]-1)][1]
IndexError: invalid index to scalar variable.
(‘Tot. cells’, 3679327.0)
(‘Tot. area’, 3456746376.8999004)
(‘Max distance’, 69179.644669000001)

But is this the error when installing?

It seems more like the error after using the command itself. If that’s the case, please share the exact command you used, so others can help. Also, if you could reproduce the error with North Carolina dataset, that would be even better.

Vero

Traceback (most recent call last):
File "/home/jefe/.grass7/addons/scripts/r.width.funct",
line 135, in <module>
   sys.exit(main())
File "/home/jefe/.grass7/addons/scripts/r.width.funct",
line 84, in main
   prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
File "/home/jefe/.grass7/addons/scripts/r.width.funct",
line 128, in findint
   z1, z2, f1, f2 = kl[int(Xf[0])][0], kl[int(Xf[0]-1)][0],
kl[int(Xf[0])][1], kl[int(Xf[0]-1)][1]
IndexError: invalid index to scalar variable.
('Tot. cells', 3679327.0)
('Tot. area', 3456746376.8999004)
('Max distance', 69179.644669000001)

If that's the case, please share the exact command you used,

please post also g.region -p.

I remember there is sometimes such an error if the region isn't set right.

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html

[keep the discussion always on the ML!]

Gesendet: Donnerstag, 21. Februar 2019 um 11:25 Uhr

Von: "Juan Lopez" <cubarro@gmail.com>
An:
Betreff: Re: [GRASS-user] r.width.funct in correct version

Dear Helmut.
This is the output of g.region command:

GRASS 7.6.0 (nc):/departamento/Test/nc_basic_spm > g.region -p
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: a=6378137 es=0.006694380022900787
north: 228500
south: 215000
west: 630000
east: 645000
nsres: 10
ewres: 10
rows: 1350
cols: 1500
cells: 2025000

and what is the exact r.width.funct command you used?

see

https://grass.osgeo.org/grass74/manuals/addons/r.width.funct.html

for an example:

###########
g.region raster=elevation -p

# Calculate flow direction
r.stream.extract elevation=elevation threshold=1000 \
direction=direction

# Create outlet point
echo "637304.924954,218617.100523" | v.in.ascii input=- sep=',' out=outlet

# Convert outlet point to raster
v.to.rast input=outlet type=point output=outlet use=cat

# Calculate distance to outlet map
r.stream.distance -o stream_rast=outlet \
direction=direction distance=dist2out

# Calculate width function
r.width.funct map=dist2out image=/tmp/my_basin
###########

kind regards
Helmut

I get the same error that Juan gets, both with his commands and with those in the example in the manual page (and both in grass76 and trunk).

[omitting the rest for brevity]

r.width.funct map=dist2out image=/tmp/my_basin
100%
Tot. cells 88407.0
Tot. area 8840700.0
Max distance 7714.591101
Traceback (most recent call last):
File “/home/veroandreo/.grass7/addons/scripts/r.width.funct”, line 135, in
sys.exit(main())
File “/home/veroandreo/.grass7/addons/scripts/r.width.funct”, line 84, in main
prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
File “/home/veroandreo/.grass7/addons/scripts/r.width.funct”, line 128, in findint
z1, z2, f1, f2 = kl[int(Xf[0])][0], kl[int(Xf[0]-1)][0], kl[int(Xf[0])][1], kl[int(Xf[0]-1)][1]
IndexError: invalid index to scalar variable.

No idea…

Maybe Madi can help us out here :slight_smile:

Vero

El jue., 21 feb. 2019 a las 11:37, Helmut Kudrnovsky (<hellik@web.de>) escribió:

[keep the discussion always on the ML!]

Gesendet: Donnerstag, 21. Februar 2019 um 11:25 Uhr

Von: “Juan Lopez” <cubarro@gmail.com>
An:
Betreff: Re: [GRASS-user] r.width.funct in correct version

Dear Helmut.
This is the output of g.region command:

GRASS 7.6.0 (nc):/departamento/Test/nc_basic_spm > g.region -p
projection: 99 (Lambert Conformal Conic)
zone: 0
datum: nad83
ellipsoid: a=6378137 es=0.006694380022900787
north: 228500
south: 215000
west: 630000
east: 645000
nsres: 10
ewres: 10
rows: 1350
cols: 1500
cells: 2025000

and what is the exact r.width.funct command you used?

see

https://grass.osgeo.org/grass74/manuals/addons/r.width.funct.html

for an example:

###########
g.region raster=elevation -p

Calculate flow direction

r.stream.extract elevation=elevation threshold=1000
direction=direction

Create outlet point

echo “637304.924954,218617.100523” | v.in.ascii input=- sep=‘,’ out=outlet

Convert outlet point to raster

v.to.rast input=outlet type=point output=outlet use=cat

Calculate distance to outlet map

r.stream.distance -o stream_rast=outlet
direction=direction distance=dist2out

Calculate width function

r.width.funct map=dist2out image=/tmp/my_basin
###########

kind regards
Helmut


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

Hi,

···

Margherita Di Leo

Thank you Margherita Di Leo, Veronica, Helmut and Nikos.

Trying to show some of my searches, I found an explanation of that IndexError in python discussion.
I seems to be a python specific problem. But I am not sure nor able to use it…

This is the link
https://stackoverflow.com/questions/32978575/how-to-fix-indexerror-invalid-index-to-scalar-variable/32979196

It is curious that previous grass versions works perfect with the same r.width.funct

Regards

···

Prof. Juan Ygnacio López Hernández Ing. MSc. PhD.
Universidad de Los Andes
Escuela de Ingeniería Forestal
Mérida, Venezuela.
Tel. ++58 426 3185690

Hi,

I could not reproduce the error. To me the example just works, there are only some deprecation warnings.

r.width.funct map=dist2out image=test
100%
Tot. cells 88407.0
Tot. area 8840700.0
Max distance 7714.591101
/usr/lib64/python2.7/site-packages/matplotlib/cbook.py:136: MatplotlibDeprecationWarning: The WX backend is deprecated. It’s untested and will be removed in Matplotlib 2.2. Use the WXAgg backend instead. See Matplotlib usage FAQ for more info on backends.
warnings.warn(message, mplDeprecation, stacklevel=1)

···

Margherita Di Leo

margherita wrote

Hi,

I could not reproduce the error. To me the example just works, there are
only some deprecation warnings.

r.width.funct map=dist2out image=test
100%
Tot. cells 88407.0
Tot. area 8840700.0
Max distance 7714.591101
/usr/lib64/python2.7/site-packages/matplotlib/cbook.py:136:
MatplotlibDeprecationWarning: The WX backend is deprecated. It's untested
and will be removed in Matplotlib 2.2. Use the WXAgg backend instead. See
Matplotlib usage FAQ for more info on backends.
  warnings.warn(message, mplDeprecation, stacklevel=1)

Width Function | quantiles

883 | 0.05
1756 | 0.15
2763 | 0.3
3218 | 0.4
3661 | 0.5
4218 | 0.6
4893 | 0.7
5926 | 0.85
6984 | 0.95

Done!

Kind regards,

tested here with

GRASS Version: 7.4.2
GRASS SVN revision: r73591
Build date: 2018-10-23
Build platform: x86_64-w64-mingw32
GDAL: 2.3.2
PROJ.4: 5.2.0
GEOS: 3.7.0
SQLite: 3.17.0
Python: 2.7.14
wxPython: 2.8.12.1
Platform: Windows-7-6.1.7601-SP1 (OSGeo4W)

++++++++++
r.width.funct --verbose map=dist2out@user1 image=C:\temp\baer\test.png
('Tot. cells', 88407.0)
('Tot. area', 8840700.0)
('Max distance', 7714.591101)
Traceback (most recent call last):
  File "C:\Users\KUDRNOVSKY\AppData\Roaming\GRASS7\addons/sc
ripts/r.width.funct.py", line 135, in <module>
    sys.exit(main())
  File "C:\Users\KUDRNOVSKY\AppData\Roaming\GRASS7\addons/sc
ripts/r.width.funct.py", line 84, in main
    prc[0,0] , prc[0,1] = findint(kl,0.05) , 0.05
  File "C:\Users\KUDRNOVSKY\AppData\Roaming\GRASS7\addons/sc
ripts/r.width.funct.py", line 128, in findint
    z1, z2, f1, f2 = kl[int(Xf[0])][0], kl[int(Xf[0]-1)][0],
kl[int(Xf[0])][1], kl[int(Xf[0]-1)][1]
IndexError: invalid index to scalar variable.
+++++++++

still the same error

-----
best regards
Helmut
--
Sent from: http://osgeo-org.1560.x6.nabble.com/Grass-Users-f3884509.html

It should be fixed in r74157. Testing welcome.

Regards,

···

Margherita Di Leo