[GRASS-user] length according to v.to.db and other vector modules

Maciej Sieczka tutey at o2.pl
Thu Oct 11 14:09:59 EDT 2007


Hi,

The line's length is exactly 50.15:

$ echo "L 2
571593.1 5722275.5
571643.25 5722275.5
" | v.in.ascii -n out=line form=standard

But, v.to.db says it's slightly longer:

$ v.to.db -p line opt=length col=dummy
cat|length
1|50.1500000000233

Is this is an error, or something inevitable due to floating
point numbers representation in computers?

I noticed this issue when I tried to use the output from
v.to.db as an input for other commands in scripts. This lead
to errors. Example:

To create points at certain locations along the above
created line I wanted to use v.segment. I also needed points
at both nodes of the line. Since v.to.db reported the line's
legth as 50.1500000000233, I used that creating an input
file for v.segment:

$ cat offsets
P 1 1 0
(49 offsets follow here)
P 51 1 50.1500000000233

But, v.segment failed to proccess it properly, saying:

$ cat offsets | v.segment in=line out=line_offs
WARNING: Cannot get point on line: cat = 1
offset = 50.150000 (line length = 50.150000)
         P 51 1 50.1500000000233

I noticed that also eg. v.what and v.distance report lengths
trunctated to 6 decimal places. Is that OK?

Maciek




More information about the grass-user mailing list