[GRASS-dev] [GRASS GIS] #2368: Python version of r.grow does not support shrinking
GRASS GIS
trac at osgeo.org
Sat Sep 6 17:33:36 PDT 2014
#2368: Python version of r.grow does not support shrinking
----------------------------------------------------------------+-----------
Reporter: wenzeslaus | Owner: grass-dev@…
Type: enhancement | Status: new
Priority: normal | Milestone: 7.1.0
Component: Raster | Version: svn-trunk
Keywords: r.grow, r.grow.distance, r.buffer, r.buffer.lowmem | Platform: Unspecified
Cpu: Unspecified |
----------------------------------------------------------------+-----------
Comment(by glynn):
Replying to [comment:2 wenzeslaus]:
> > > I'm not sure if negative distances can be added to
`r.grow.distance`.
Having thought about this some more ...
In the case where you're interested in the distance= map (rather than the
value= map), distance inside is just as meaningful as distance outside.
An r.shrink.distance module would be structurally similar (i.e. a near
clone), so it makes sense to try to keep them in the same module.
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).
The value= map (which normally contains the value of the nearest non-null
cell) would be meaningless in this case; the value of the nearest null
cell is always null.
Alternatively, it could calculate both positive and negative distances
simultaneously, and could probably even use the same arrays for both
calculations.
(Would we need to add a flag to enable negative distances? It's an
incompatible change, but the module is new in 7.0. Are the 7.0 betas
something with we now need to retain compatibility?).
For non-null cells, the {old,new}_{x,y}_row and dist_row arrays always
contain zero (i.e. the x and y offsets and the distance to the nearest
non-null cell are always zero), and the {old,new}_val_row arrays (the
value of the nearest non-null cell) always contain the current cell's
value. This is all information which can be deduced directly from the
current input row.
It's only for null cells where the arrays contain accumulated results.
The only drawback is that lookups would be complicated slightly, but the
performance impact should be trivial.
--
Ticket URL: <http://trac.osgeo.org/grass/ticket/2368#comment:3>
GRASS GIS <http://grass.osgeo.org>
More information about the grass-dev
mailing list