[GRASS-dev] Re: [GRASS-user] how to measure distances in a constrained space

Glynn Clements glynn at gclements.plus.com
Thu Nov 20 12:11:55 EST 2008


Glynn Clements wrote:

> > In any case, the specific purpose of r.grow.distance is:
> > 
> >    r.grow.distance generates a raster map representing the distance to
> >    the nearest non-null cell in the input map.
> 
> It now has an additional function: to generate a raster map containing
> the value of the nearest cell.
> 
> >From this, it is possible to mimic the behaviour of r.grow, but
> substantially faster, with e.g.:
> 
> # equivalent to: r.grow input=$inmap output=$outmap radius=$radius metric=$metric
> temp=r.grow.tmp.$$
> r.grow.distance in=$inmap distance=$temp.dist value=$temp.near metric=$metric
> r.mapcalc "$outmap = if($temp.dist < $radius,$temp.near,null())"
> r.colors $outmap rast=$temp.near
> g.remove rast=$temp.dist,$temp.near
> 
> Whereas the worst-case time taken by r.grow is proportional to the
> square of the buffer radius, the above is proportional only to the
> area of the map, regardless of the buffer radius.
> 
> I'll replace r.grow in 7.0 with a script along these lines.

Done.

I've also fixed the spelling of "euclidean" in both r.grow and
r.grow.distance, in 6.4 and 7.0.

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-user mailing list