[GRASSLIST:7864] Re: distance between two points

Ellen De Beuckeleer ellen.debeuckeleer at incgeo.be
Thu Aug 11 02:38:40 EDT 2005

I'm not an expert (yet ;)), but this is what I would try:

create a raster layer with all cells containing for example 1 (same 
region as you want to use), dan run r.cost with this raster layer as 
input and the vector layer containing the one point of interest as 
starting point vector map. (If you don't know how to do this 
commandline, you can use the GUI.) I haven't tried it yet, but I think 
this might work. If it doesn't, check the coordinates (east and north) 
of the point of interest and you can use this in the r.cost instead of 
the vector layer. Another possibility could be to convert the vector 
point layer into a raster. After the r.cost you can run r.drain using 
the result of r.cost. This will compute the shortest path between the 
point of interest and another point that you need to specify. If you 
took cost 1 for every cell, I think this will find the line you need. If 
you use r.rast.leg to show the result, you find the distance in the 
starting point of the line, namely your point of interest. If the point 
to specify is a raster cell, you can get the coordinates by using 
d.where. You can find this command in the GUI at Display->show 
geographic position.

Jason Horn wrote:

> To put it simply:
> I have a vector layer that contains a point of interest.  I'd like to  
> know the distance from that point to every cell in a raster layer  
> that covers the same area.  I did look through all the commands I did  
> not find anything that allows one to compare features between vector  
> and raster layers.
> On Aug 8, 2005, at 3:56 PM, David Finlayson wrote:
>> Have you looked through the commands and not found what you need
>> there?  These commands: v.distance, d.geodesic, d.measure, r.buffer,
>> r.distance all do a variation on the theme.
>> If these don't work, maybe you can describe what you are trying to
>> accomplish in more detail.
>> David
>> On 8/8/05, Jason Horn <jhorn at bu.edu> wrote:
>>> Is there a grass function that will calculate the distance between
>>> two points on a vector layer?  How about between a point on a vector
>>> layer and a cell on a raster layer?
>> -- 
>> David Finlayson
>> Marine Geology & Geophysics
>> School of Oceanography
>> Box 357940
>> University of Washington
>> Seattle, WA  98195-7940
>> USA
>> Office: Marine Sciences Building, Room 112
>> Phone: (206) 616-9407
>> Web: http://students.washington.edu/dfinlays


Kempische steenweg 297 bus 2
3500 Hasselt
tel: +32 (0)11 45 20 16
fax: +32 (0)11 45 20 17

More information about the grass-user mailing list