[GRASS-user] r.basin error

pelempito hoyodepelempito at yahoo.com
Mon Oct 22 09:54:21 PDT 2018


I tryed to run the r.basin addon for almost 4000 basins. Approximately 10%
of the basins end without the .csv parameters file. Digging deeper into the
command output, I spotted the following error at the end of the log from

Traceback (most recent call last):
  File "/home/jr/.grass7/addons/scripts/r.width.funct", line
132, in <module>
  File "/home/jr/.grass7/addons/scripts/r.width.funct", line
85, in main
    prc[2,0] , prc[2,1] = findint(kl,0.3) , 0.3
  File "/home/jr/.grass7/addons/scripts/r.width.funct", line
125, 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]
TypeError: only length-1 arrays can be converted to Python


An ERROR occurred running r.basin
Please check for error messages above or try with another pairs of outlet

I think that r.basin stops after this error occurs, which may prevent
r.basin from generating the .csv parameter file for a given basin. I
researched a bit about the scalars in Python, and found  this post
(sorry for cross referencing), which refers that "non-numpy functions ...
don't play nicely with numpy arrays", but I couldn't make more follow up.

The error I just found can be reproduced by importing the raster DEM
included in  this ZIP file
<http://geografiafisica.org/consigna/visitante/grass/hydrodem.zip>   into
GRASS, and running the following command (I have more coordinates for which
r.basin fails as well):

r.basin --overwrite --verbose map=hydrodem prefix=cuenca13
coordinates=335595,2066655 threshold=22 dir=/tmp/tst

The raster is a subset of the tile Entity ID SRTM1N18W071V3, from the SRTM 1
Arc-Second Global DEM, post-treated by myself with the r.hydrodem addon.

I unsuccessfully tried to solve the issue by updating the region with both
the -a flag and the align parameter, since I read in the forum about that
trick as a possible workaround as well.

My GRASS region output is included below:

g.region -p                                                                     
projection: 1 (UTM)
zone:       19
datum:      wgs84
ellipsoid:  wgs84
north:      2068530
south:      2017320
west:       314970
east:       353400
nsres:      30
ewres:      30
rows:       1707
cols:       1281
cells:      2186667

And this is the r.info command output for the raster map hydrodem:

r.info map=hydrodem at PERMANENT                                                   

 | Map:      hydrodem at PERMANENT             Date: Mon Oct 22 10:04:29 2018   
 | Mapset:   PERMANENT                      Login of Creator: jr             
 | Location: hydrodemocoa                                                    
 | DataBase: /home/jr/Documentos/grass/tst                                   
 | Title:     ( hydrodem )                                                   
 | Timestamp: none                                                           

 |   Type of Map:  raster               Number of Categories: 0              
 |   Data Type:    DCELL                                                     
 |   Rows:         1707                                                      
 |   Columns:      1281                                                      
 |   Total Cells:  2186667                                                   
 |        Projection: UTM (zone 19)                                          
 |            N:    2068530    S:    2017320   Res:    30                    
 |            E:     353400    W:     314970   Res:    30                    
 |   Range of data:    min = 0.946  max = 2340.517                           
 |   Data Description:                                                       
 |    generated by r.in.gdal                                                 
 |   Comments:                                                               
 |    r.in.gdal -e input="/home/jr/Documentos/grass/tst/hydrodem.tif" outp\  
 |    ut="hydrodem" memory=300 offset=0                                      


I appreciate any help. I also would like to thank the developers for this
great addon.


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

More information about the grass-user mailing list