Opened 9 years ago

Last modified 5 years 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 by neteler, 9 years ago

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?

in reply to:  1 comment:2 by hellik, 9 years ago

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

comment:4 by martinl, 9 years ago

Milestone: 7.0.47.0.5

comment:5 by neteler, 8 years ago

Milestone: 7.0.57.0.6

in reply to:  3 comment:6 by hellik, 8 years ago

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 8 years ago by hellik (previous) (diff)

comment:7 by hellik, 7 years ago

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 by hellik, 7 years ago

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 by hellik, 7 years ago

Component: AddonsRaster
Platform: MSWindows 7MSWindows 8

in reply to:  3 ; comment:10 by hellik, 7 years ago

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?

in reply to:  10 ; comment:11 by marisn, 7 years ago

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.

in reply to:  11 comment:12 by mmetz, 7 years ago

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 by martinl, 7 years ago

Milestone: 7.2.3

Ticket retargeted after milestone closed

comment:14 by martinl, 7 years ago

Milestone: 7.2.4

comment:15 by neteler, 5 years ago

Milestone: 7.2.47.8.3
Version: svn-releasebranch72git-releasebranch78

comment:16 by hellik, 5 years ago

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 by hellik, 5 years ago

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.