[GRASS-user] working with vectors

Hamish hamish_b at yahoo.com
Sat May 16 01:22:44 EDT 2009


Achim:
> > , measure length of lines even in an latlong projection...
Moritz:
> v.to.db, although I'm not 100% sure how that deals with
> lat-long. Only comment in the man page:
> 
> "When calculating perimeters in Latitude-Longitude
> locations, the geodesic distance between the vertices is
> used."
> 
> I would suppose that this is the same for line length...

actually ??, although I do get correct looking results in meters
from v.to.db option=length, it looks like v.to.db/lines.c needs
to have in a few other places:

- len = Vect_line_length(Points);
+ if (G_projection() == PROJECTION_LL)
+     len = Vect_line_geodesic_length(Points);
+ else
+     len = Vect_line_length(Points);

??? not sure when that code is used though --
it also uses length() instead (from v.to.db/calc.c) which uses
G_distance() (LatLon-aware), which is probably where the
reasonable output comes from.


perhaps we need to make a new V_distance(Points) lib fn that,
like G_distance(), automatically switches to geodesic mode when
the location is lat/lon?

test:

test_lines.vasc
L 2 1
 166 -45
 167 -45
 1 1
L 2 1
 166 -46
 166 -47
 1 2
L 2 1
 167 -44
 168 -45
 1 3

v.in.ascii in=test_lines.vasc out=test_lines format=standard -n
v.db.addtable test_lines col='length_m double'
v.to.db test_lines opt=length colum=length_m
v.db.select test_lines

vertical line should be 1 deg lat dist (~ 1852m * 60)
horiz line should be 1 deg lon dist (~ 1852 * 60 * 0.707 here)


?,
Hamish



      



More information about the grass-user mailing list