Opened 4 years ago

Last modified 2 weeks 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.8.3
Component: Raster Version: git-releasebranch78
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 (17)

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 4 years ago by neteler

Milestone: 7.0.57.0.6

comment:6 in reply to:  3 Changed 4 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 4 years ago by hellik (previous) (diff)

comment:7 Changed 3 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 3 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 3 years ago by hellik

Component: AddonsRaster
Platform: MSWindows 7MSWindows 8

comment:10 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

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

comment:11 in reply to:  10 ; Changed 3 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 3 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 2 years ago by martinl

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:14 Changed 2 years ago by martinl

Milestone: 7.2.4

comment:15 Changed 2 weeks ago by neteler

Milestone: 7.2.47.8.3
Version: svn-releasebranch72git-releasebranch78

comment:16 Changed 2 weeks ago by hellik

isn't it some kind of a parser issue?

as it pops up also in other modules/addons, e.g.

https://lists.osgeo.org/pipermail/grass-user/2020-June/081577.html

worth to open a GH issue?

comment:17 Changed 2 weeks ago by hellik

some background information:

https://sourceforge.net/p/mingw/bugs/2358/

[...]
 You are using Microsoft's implementation of scanf(), (because that is all that MinGW has ever used for this function, and its siblings), so the behaviour is as Microsoft have specified it, (and there appears to be nothing in their documentation to suggest how infinities and nans might be converted,
[...]
You may consider Microsoft's implementation to be broken -- and you may well be right -- but good luck with trying to get them to acknowledge that, much less fix it.

AFAIR there was also some discussion some times ago how winGRASS (not) handling NaN in raster data. (can't find ticket or thread at the moment).

Note: See TracTickets for help on using tickets.