[GRASS-user] Straight-line distance of raster from point

Joshua Arnott josh at snorfalorpagus.net
Sat Mar 12 05:17:56 EST 2011

On 12/03/2011 4:32 am, Hamish wrote:
> Joshua wrote:
>> For each cell in a raster I'd like to calculate the
>> straight line distance (from it's centre) to a vector point,
>> with the output stored as the value of a new raster. I've
>> had a look through the manual and the archives, but I can't
>> find any obvious way to do this.
> just a single vector point?
> the easiest way is to work backwards with r.cost, then multiply
> by the cell size. but that is not exactly accurate (see help
> page).
> for something more exact you'd have to use r.mapcalc with
> something like  sqrt( (x() - x_coord)^2 + (y() - y_coord)^2 ).
> Hamish
Thanks Hamish. I am continually surprised at how powerful r.mapcalc is.


More information about the grass-user mailing list