Opened 4 years ago

Last modified 20 months ago

#2919 new defect

Use SFD above this threshold - infinity doesn't work in r.stream.extract

Reported by: PitStop Owned by: grass-dev@…
Priority: normal Milestone: 7.2.4
Component: Raster Version: svn-releasebranch72
Keywords: r.stream.extract Cc:
CPU: x86-64 Platform: MSWindows 8

Description

Hi There,

I'm trying to delineate a watershed and also extract the streams within using here for reproduction the NC data set.

r.watershed elevation=elev_srtm_30m@PERMANENT threshold=1000 accumulation=accu drainage=drain basin=basin

and then

r.stream.extract elevation=elev_srtm_30m@PERMANENT accumulation=accu@user1 threshold=1000 stream_raster=stream_r stream_vector=stream_v

leads to

ERROR: Missing value for parameter <d8cut>

while the accumulation map is specified in the command and therefor d8cut shouldn't be used.

The same error was report http://osgeo-org.1560.x6.nabble.com/r-stream-extract-grass7-addon-td5018389.html#a5018528

g.version -g

version=7.0.3
date=2016
revision=67691
build_date=2016-01-28
build_platform=x86_64-w64-mingw32

Change History (14)

comment:1 Changed 4 years ago by neteler

Milestone: 7.0.4

I just tried on Linux, no such issue:

g.region raster=elev_srtm_30m
r.watershed elevation=elev_srtm_30m@PERMANENT threshold=1000
   accumulation=accu drainage=drain basin=basin
r.stream.extract elevation=elev_srtm_30m@PERMANENT accumulation=accu@user1 \
   threshold=1000 stream_raster=stream_r stream_vector=stream_v

No errors occured.

g.version -g
version=7.0.4svn
date=2016
revision=67880M
build_date=2016-01-20
build_platform=x86_64-pc-linux-gnu

You marked it as "addon" while it is part of core GRASS 7. Is it possible that you are using a leftover Addon version of r.stream.extract?

comment:2 in reply to:  1 Changed 4 years ago by hellik

Replying to neteler:

I just tried on Linux, no such issue:

g.region raster=elev_srtm_30m
r.watershed elevation=elev_srtm_30m@PERMANENT threshold=1000
   accumulation=accu drainage=drain basin=basin
r.stream.extract elevation=elev_srtm_30m@PERMANENT accumulation=accu@user1 \
   threshold=1000 stream_raster=stream_r stream_vector=stream_v

No errors occured.

g.version -g
version=7.0.4svn
date=2016
revision=67880M
build_date=2016-01-20
build_platform=x86_64-pc-linux-gnu

You marked it as "addon" while it is part of core GRASS 7. Is it possible that you are using a leftover Addon version of r.stream.extract?

Confirmed here in winGRASS. the default value of d8cut seems not to be recognized by parser in winGRASS again. see the mentioned ML entry.

comment:3 Changed 4 years ago by neteler

comment:4 Changed 4 years ago by martinl

Milestone: 7.0.47.0.5

comment:5 Changed 3 years ago by neteler

Milestone: 7.0.57.0.6

comment:6 in reply to:  3 Changed 3 years ago by hellik

Replying to neteler:

I see: the change r53993 (remove default: infinity) was not applied to relbranch7, see

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L113

Seems that "infinity" is not understood by the parser?

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L195

still an issue in all g7-variants (winGRASS).

Last edited 3 years ago by hellik (previous) (diff)

comment:7 Changed 2 years ago by hellik

Milestone: 7.0.67.2.3
Summary: r.stream.extract errorUse SFD above this threshold - infinity doesn't work in r.stream.extract
Version: 7.0.3svn-releasebranch72

changing title.

see also #3432

comment:8 Changed 2 years ago by hellik

taken from #3432

still an issue in relbranch 7

System Info                                                                     
GRASS version: 7.3.svn                                                          
GRASS SVN revision: r71600                                                      
Build date: 2017-10-27                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 2.2.1                                                                     
PROJ.4: 4.9.3                                                                   
GEOS: 3.5.0                                                                     
SQLite: 3.17.0                                                                  
Python: 2.7.5                                                                   
wxPython: 2.8.12.1                                                              
Platform: Windows-8-6.2.9200 (OSGeo4W) 

and trunk

System Info                                                                     
GRASS version: 7.2.2                                                            
GRASS SVN revision: r71496                                                      
Build date: 2017-09-20                                                          
Build platform: x86_64-w64-mingw32                                              
GDAL: 2.2.1                                                                     
PROJ.4: 4.9.3                                                                   
GEOS: 3.5.0                                                                     
SQLite: 3.17.0                                                                  
Python: 2.7.5                                                                   
wxPython: 2.8.12.1                                                              
Platform: Windows-8-6.2.9200 (OSGeo4W)

comment:9 Changed 2 years ago by hellik

Component: AddonsRaster
Platform: MSWindows 7MSWindows 8

comment:10 in reply to:  3 ; Changed 2 years ago by hellik

Replying to neteler:

I see: the change r53993 (remove default: infinity) was not applied to relbranch7, see

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L113

Seems that "infinity" is not understood by the parser?

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L195

yes, it seems to be a parser issue. but why it works then in linux?

comment:11 in reply to:  10 ; Changed 2 years ago by marisn

Replying to hellik:

Seems that "infinity" is not understood by the parser?

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L195

yes, it seems to be a parser issue. but why it works then in linux?

My guess - input.d8cut->answer contains extra chars (CR/LF issue?) and thus changing line to read:

if (strncmp(input.d8cut->answer, "infinity", 8) == 0) {

would solve the issue. Still, if it is so, then it is worth to digg deeper to see why it is failing as strcmp is used in many modules.

comment:12 in reply to:  11 Changed 2 years ago by mmetz

Replying to marisn:

Replying to hellik:

Seems that "infinity" is not understood by the parser?

https://trac.osgeo.org/grass/browser/grass/branches/releasebranch_7_0/raster/r.stream.extract/main.c#L195

yes, it seems to be a parser issue. but why it works then in linux?

My guess - input.d8cut->answer contains extra chars (CR/LF issue?)

there can't be CR/LF, answers are terminated by '\0'

and thus changing line to read:

if (strncmp(input.d8cut->answer, "infinity", 8) == 0) {

would solve the issue.

The d8cut option is not required, therefore I removed the problematic default answer "infinity" and changed

-    if (strcmp(input.d8cut->answer, "infinity") == 0) {
+    if (!input.d8cut->answer) {

in trunk and relbr72 with r71607,8.

Still, if it is so, then it is worth to digg deeper to see why it is failing as strcmp is used in many modules.

I guess that the MS Windows version of sscanf does not recognize infinity as a floating point number, while the Linux version does.

comment:13 Changed 20 months ago by martinl

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:14 Changed 20 months ago by martinl

Milestone: 7.2.4
Note: See TracTickets for help on using tickets.