[GRASS-dev] [GRASS GIS] #2686: r.hazard.flood error output

#2686: r.hazard.flood error output
--------------------------+---------------------------------
Reporter: zimbogisgeek | Owner: grass-dev@…
     Type: defect | Status: new
Priority: critical | Milestone: 7.0.1
Component: Python | Version: svn-releasebranch70
Keywords: | CPU: All
Platform: All |
--------------------------+---------------------------------
Running r.hazard.flood produces an erroneous map mainly because in the
r.hazard.py script there is a mistake in calculating the final map. The
command that produces the error is

grass.mapcalc("$r_flood_map = $rast1 / $rast1", r_flood_map = r_flood_map,
rast1 = 'r_flood_th')

which should be

  grass.mapcalc("$r_flood_map = $rast1 / $rast2", r_flood_map =
r_flood_map, rast1 = 'r_flood_th', rast2 = 'r_flood')

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: critical | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------
Changes (by neteler):

* cc: madi (added)
* keywords: => r.hazard.flood
* component: Python => Addons

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:1&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------
Changes (by madi):

* priority: critical => normal

Comment:

Hi, thank you for pointing this out, but does this actually produce an
erroneous result? could you give an example? Thanks

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:2&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------

Comment (by lucadelu):

Hi Madi, but the code is dividing the same maps

{{{
"$r_flood_map = $rast1 / $rast1"
}}}

so it return for every pixel 1, is it the right behavior?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:3&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------

Comment (by madi):

Replying to [comment:3 lucadelu]:
> Hi Madi, but the code is dividing the same maps
>
> {{{
> "$r_flood_map = $rast1 / $rast1"
> }}}
>
> so it return for every pixel 1, is it the right behavior?

yes, the expected result is a binary map (yes=1, no=null)
Thanks,
madi

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:4&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------

Comment (by neteler):

Replying to [comment:4 madi]:
> Replying to [comment:3 lucadelu]:
> > Hi Madi, but the code is dividing the same maps
> >
> > {{{
> > "$r_flood_map = $rast1 / $rast1"
> > }}}
> >
> > so it return for every pixel 1, is it the right behavior?

The behaviour in question comes from r.mapcalc:

> yes, the expected result is a binary map (yes=1, no=null)

Here a quick test:

{{{
r.mapcalc "result = 1/1"
r.univar -g result | grep 'min\|max\|null'
null_cells=0
min=1
max=1

r.mapcalc "result2 = 0/0"
r.info result2 | grep 'min\|max\|null'
  | Range of data: min = NULL max = NULL

r.mapcalc "result3 = null()/null()"
r.info result3 | grep 'min\|max\|null'
  | Range of data: min = NULL max = NULL
}}}

Is this what should happen in r.hazard.flood?

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:5&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: new
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------

Comment (by madi):

Replying to [comment:5 neteler]:
> Replying to [comment:4 madi]:
> > Replying to [comment:3 lucadelu]:
> > > Hi Madi, but the code is dividing the same maps
> > >
> > > {{{
> > > "$r_flood_map = $rast1 / $rast1"
> > > }}}
> > >
> > > so it return for every pixel 1, is it the right behavior?
>
> The behaviour in question comes from r.mapcalc:
>
> > yes, the expected result is a binary map (yes=1, no=null)
>
> Here a quick test:
>
> {{{
> r.mapcalc "result = 1/1"
> r.univar -g result | grep 'min\|max\|null'
> null_cells=0
> min=1
> max=1
>
> r.mapcalc "result2 = 0/0"
> r.info result2 | grep 'min\|max\|null'
> | Range of data: min = NULL max = NULL
>
> r.mapcalc "result3 = null()/null()"
> r.info result3 | grep 'min\|max\|null'
> | Range of data: min = NULL max = NULL
> }}}
>
> Is this what should happen in r.hazard.flood?

Precisely so.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:6&gt;
GRASS GIS <http://grass.osgeo.org>

#2686: r.hazard.flood error output
---------------------------+---------------------------------
  Reporter: zimbogisgeek | Owner: grass-dev@…
      Type: defect | Status: closed
  Priority: normal | Milestone: 7.0.1
Component: Addons | Version: svn-releasebranch70
Resolution: invalid | Keywords: r.hazard.flood
       CPU: All | Platform: All
---------------------------+---------------------------------
Changes (by madi):

* status: new => closed
* resolution: => invalid

Comment:

I double checked the code and unless I can't see the obvious it looks
alright to me. Therefore I'm closing this ticket as invalid. Please feel
free to reopen it if something looks amiss. However, the expected result
of this tool is indeed a binary map.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2686#comment:7&gt;
GRASS GIS <http://grass.osgeo.org>