# [GRASS-user] v.distance anything to anything

Moritz Lennert mlennert at club.worldonline.be
Tue Oct 16 01:14:50 PDT 2012

```On 16/10/12 10:02, Markus Metz wrote:
> 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.

Ok.

>>
>> 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.

Ok, this makes it clear. Thanks !

>
> 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.

Yes, that's why documentation is so important on all this.

Moritz

```