[GRASS-user] v.distance anything to anything

Markus Metz markus.metz.giswork at gmail.com
Tue Oct 16 01:02:11 PDT 2012


On Tue, Oct 16, 2012 at 12:52 AM, Moritz Lennert
<mlennert at club.worldonline.be> wrote:
> On 15/10/12 16:30, Markus Metz wrote:
>
>>> So how does it calculate the distance between two lines (lines or
>>> boundaries) ? Between closest vertices ? What about lines that cross
>>> several
>>> other lines, or lines that cross each other at several points ?
>>
>>
>> For lines to lines, say line A to line B, it calculates shortest
>> distance of each vertex in A with each segment (not vertex) in B. So
>> far, this is the same like in the original version, results are
>> identical.
>
>
> The original version did not have line to line...

What I meant was that this is equivalent to the shortest distance of
several points to a line, regarding points as line vertices.

>
>
>>>
>>>
>>>> In GRASS 6, v.distance can calculate distances only from
>>>> point,centroid to point,line,boundary,centroid,area.
>>>
>>>
>>>
>>> AFAIK, this was due to the conceptual issue mentioned above. I think that
>>> the answer has to be clearly explained in the manual because they are not
>>> as
>>> straightforward. And a first rapid test shows that these issues seem to
>>> be
>>> problematic in your implementation:
>>>
>>> http://164.15.12.207/grass/v_distance_lines.png
>>> http://164.15.12.207/grass/v_distance_areas.png
>>>
>>> red: from features (quickly digitized test data available here:
>>> http://164.15.12.207/grass/v_distance_testdata.tgz)
>>> black: to features (roadsmajor and urbanarea from nc_spm_08)
>>> green: connecting lines between from and to feature
>>
>>
>> Thanks for testing! These issues should be fixed, at least conforming
>> to my explanation above, in r53401.
>
>
> Much better, thanks ! Just one issue still with the area2area case for the
> test polygon with cat=2:
>
> http://164.15.12.207/grass/v_distance_areas2.png
>
> The connection line/point doesn't touch the the polygon in the from map.

But it is inside the polygon of the 'from' map. In this
implementation, any shared location is as good as any other.
Calculating an intersection is costlier than to check if a vertex is
inside a polygon. The vertex of the boundary of the 'to' area is
inside the 'from' area, thus a common location. For speed reasons, the
distance is set to zero and no further tests are done.

The results can be unexpected for 'to' areas with isles, because
v.distance (in all versions) does not require a 'to' feature to have a
category, which also means that isles inside areas which themselves
can be areas without centroids are regarded as valid 'to' features,
just without category. But even though the results can be unexpected,
I would leave them as such, otherwise 'to' feature would need to have
a category, potentially leading to also different results for points
to lines which has always been supported.

Markus M


More information about the grass-user mailing list