[GRASS-user] Forcing polyline nodes through a point

Dwight Needels needels at translucida.com
Fri May 29 13:46:44 EDT 2009


On May 29, 2009, at 4:50 AM, Hamish wrote:
>
> Dwight wrote:
>> I am looking for a way to force the polylines (from GPS
>> tracks) to terminate at the points (from averaged
>> waypoints). One possibility would be to snap each terminal
>> node to the nearest point (within a threshold), with the
>> point coordinates taking precedence.
>
>
> Hi Dwight,
>
> try 'v.distance output=' + v.patch + v.clean.
>
>
> Hamish

Thanks, Hamish. That is very close to what I want, but I am having  
some difficulty closing the gap.

In the simplest circumstance, the part of the line closest to the  
point is the node on the end, so your suggested procedure extends the  
line to the point. However, the original node is still a node (rather  
than a vertex), so there is a simple line segment attached to the end  
of a polyline segment. I was hoping to find a way to end up with a  
single polyline so that any kink generated at the end will be  
straightened out using v.generalize method=sliding_averaging.

Any ideas on how to accomplish this? Can two-line nodes be converted  
to a vertex within a threshold distance of a reference point or if one  
of the connected line segments is shorter than a threshold?

Under other circumstances, the part of the line closest to the point  
is somewhere along the line segment rather than at the end, resulting  
in a "Y" configuration. I thought I could use v.clean to break the  
original polyline where the v.distance segment intersects, which would  
generate a dangle that could then be removed with v.clean. However, I  
had trouble with each of these steps. Here is what I did, using a  
point near each terminus of a line.

v.distance -p from=terminus to=trail from_type=point to_type=line  
output=trail_connections dmax=20 upload=dist column=dist
v.patch input=trail,trail_connections output=trail_patched
v.clean input=trail_patched output=trail_break type=line tool=break  
thresh=1
v.clean input=trail_break output=trail_rmdangle type=line  
tool=rmdangle thresh=20

v.distance created  lines that were about 6 and 13 ft long that  
intersected the trail line at about 8 and 14 ft away from each  
terminus, respectively (creating a "Y" on each end).

v.clean tool=break clipped the trail at the second intersection, but  
not the first (confirmed using v.digit). What causes this difference  
in behavior?

v.clean tool=rmdangle removed both of the line segments generated by  
v.distance, but did not remove what appears to be a 14 ft dangle  
created by the v.clean tool=break step. Why was the 14 ft dangle not  
removed (in v.digit it has a green X on one end and a red X on the  
other, and it is shorter than the threshold).

There are enough problems here that I am beginning to think that I  
don't understand what should be happening. Can someone straighten me  
out?

Thanks, -Dwight



More information about the grass-user mailing list