# [GRASS-dev] [grass-code R] v.to.db option=length: please report line's 3d length

Maciej Sieczka tutey at o2.pl
Sat Oct 13 08:14:39 EDT 2007

```Hamish wrote:
>> Maciej:
>>> Same request applies to v.distance. It apparently
>>> assumes input points are flat too. Consider 2 3d
>>> points:

> Martin wrote:
>> v.distance should be fixed in CVS

Martin

You are too quick for me to catch on with testing :). I
confim now v.distance calculates the distance between 3D
points OK. BTW - v.distance suffers the same issue you have
just fixed in v.to.db, among the others, that a dummy column
is required in -p(rint) mode.

>> (not tested with 3d lines...)

Works if both input point and line are 3d:

\$echo "571710|5722300|4|1" | v.in.ascii -zt z=3 out=pt3d --o

\$ echo "L 2
571600 5722275.5 0
571610 5722275.5 0" | v.in.ascii -zn form=standard out=l3d

\$ v.distance -pa from=pt3d to=l3d upload=cat,dist col=cat,dist
from_cat|cat|dist
1|null|103.035188

\$ echo "L 2
571600 5722275.5 1000
571610 5722275.5 1000" | v.in.ascii -zn form=standard
out=l3d --o

\$ v.distance -pa from=pt3d to=l3d upload=cat,dist col=cat,dist
from_cat|cat|dist
1|null|1001.307271

As can be seen the reported distances change as the input 3d
line moves in Z. Same happens if the 3d point changes elevation.

If *either* or both input is flat, the distance is
calculated in 2d space.

> d.what.vect will give you a 3D distance to compare
> against for an easy test.

Sorry I'm dense, but I don't get it how d.what.vect can
measure 3D distance. Can you explain?

Maciek

```