[GRASS-dev] [GRASS GIS] #2368: Python version of r.grow does not support shrinking

GRASS GIS trac at osgeo.org
Tue Aug 9 01:27:45 PDT 2016


#2368: Python version of r.grow does not support shrinking
-------------------------+-------------------------------------------------
  Reporter:  wenzeslaus  |      Owner:  grass-dev@…
      Type:              |     Status:  new
  enhancement            |
  Priority:  minor       |  Milestone:  7.2.0
 Component:  Raster      |    Version:  svn-trunk
Resolution:              |   Keywords:  r.grow, r.grow.distance, r.buffer,
       CPU:              |  r.buffer.lowmem
  Unspecified            |   Platform:  Unspecified
-------------------------+-------------------------------------------------

Comment (by mmetz):

 Replying to [comment:12 mmetz]:
 > Replying to [comment:9 neteler]:
 > > Replying to [comment:7 neteler]:
 > > > Replying to [comment:6 mmetz]:
 > > > > Replying to [comment:3 glynn]:
 > > > > > The easiest change would be to have an "invert" flag which
 caused the distance= map to contain the distance from the nearest null
 cell (currently, it's the distance from the nearest non-null cell, so the
 non-null cells themselves have a distance of 0).
 > > > >
 > > > > Attached is a minimally invasive patch to add a new flag to
 r.grow.distance, calculating the distance to the nearest null cell.
 > > >
 > > > Patch applied to trunk in r67620.
 > >
 > > Can I backport this to 7.2.0? Again I need a negative buffer...
 >
 > This is a new feature and as such does not qualify for backport.
 >
 > If you want to shrink you can use
 >
 > {{{
 > r.mapcalc "input_inv = if(isnull(input), 1, null())"
 > r.grow input=input_inv
 > }}}

 I meant r.grow.distance, not r.grow.

 >
 > Replying to [comment:10 neteler]:
 > > Just tested r.grow with a negative radius and the following error
 occurs:
 > > {{{
 > > # NC sample dataset
 > > v.in.region box
 > > v.to.rast input=box output=box use=val val=1
 > >
 > > r.grow input=box output=box_shrink radius=-20.01
 > > }}}
 >
 > The example is wrong because there are no NULL cells in the current
 region for the input raster. When growing, for each NULL cell the distance
 to the nearest non-NULL cell is calculated. When shrinking, for each non-
 NULL cell the distance to the nearest NULL cell is calculated. That means
 there must be both NULL and non-NULL cells in the input raster for the
 current region, otherwise nothing can be grown or shrunk.
 >
 > The example can not work because r.grow does not support negative
 distances.

 Support for shrinking with negative radius added to r.grow in r69110.
 Please try the example in the manual.

--
Ticket URL: <https://trac.osgeo.org/grass/ticket/2368#comment:13>
GRASS GIS <https://grass.osgeo.org>



More information about the grass-dev mailing list