3
<em>r.distance</em> locates the closest points between "objects" in two raster maps. An
4
"object" is defined as all the grid cells that have the same category
5
number, and closest means having the shortest "straight-line" distance.
6
The cell centers are considered for the distance calculation (two
7
adjacent grid cells have the distance between their cell centers).
10
The output is an ascii list, one line per pair of objects, in the following form:
11
<div class="code"><pre>
12
cat1:cat2:distance:east1:north1:east2:north2
17
<dd>Category number from map1
20
<dd>Category number from map2
23
<dd>The distance in meters between "cat1" and "cat2"
25
<dt><b>east1,north1</b>
26
<dd>The coordinates of the grid cell "cat1" which is closest to "cat2"
28
<dt><b>east2,north2</b>
29
<dd>The coordinates of the grid cell "cat2" which is closest to "cat1"
34
The -l flag outputs the category labels of the matched raster objects at the
35
beginning of the line, if they exist.
38
The -o flag reports zero distance if the input rasters are overlapping.
42
The output format lends itself to filtering. For example, to "see" lines
43
connecting each of the category pairs in two maps, filter the output using
44
awk and then into <em>d.graph</em>:
47
<div class="code"><pre>r.distance maps=map1,map2 | \
48
awk -F: '{print "move",$4,$5,"\ndraw",$6,$7}' | d.graph -m</pre></div>
51
To create a vector map of all the "map1" coordinates, filter the output into
52
awk and then into <em>v.in.ascii</em>:
55
<div class="code"><pre>r.distance maps=map1,map2 | \
56
<br>awk -F: '{print $4,$5}' | v.in.ascii format=point output=name fs=space</pre></div>
59
<em><a href="r.buffer.html">r.buffer</a></em>,
60
<em><a href="r.cost.html">r.cost</a></em>,
61
<em><a href="r.drain.html">r.drain</a></em>,
62
<em><a href="v.distance.html">v.distance</a></em>
65
Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
67
<p><i>Last changed: $Date: 2008-05-13 21:22:32 +0200 (Tue, 13 May 2008) $</i></p>