[GRASS-user] Forcing polyline nodes through a point
Dwight Needels
needels at translucida.com
Sat May 30 18:28:32 EDT 2009
Hamish,
Getting closer (I was wondering how to accomplish the extraction of
nodes from a vector... thanks!). Unfortunately, this still leaves me
with the problem of a short line segment attached to the end of the
original line by a node rather than a vertex, which can put in a kink
that remains after smoothing with v.generalize.
I followed v.to.points/v.distance/v.patch with v.build.polylines and
v.generalize method=snakes, which works as long as the only desired
nodes are associated with one line and not two (i.e. they are terminal
nodes). However, I many have other nodes that connect two line
segments at a sharp corner such as a trail fork or switchback that I
don't want to lose (convert to a vertex).
Is there a way to only convert a two-line node to a vertex if one of
the lines is shorter than a threshold or the node is within a
threshold of a terminus or reference point? Alternatively, is it
possible to patch two vectors in a way that creates a polyline where
feasible?
I want to end up with the short line segment created by v.distance
patched to the original line by a vertex rather than a node, but
without losing nodes elsewhere in the original line.
-Dwight
On May 29, 2009, at 2:08 PM, Hamish wrote:
>
> ok, try 'v.to.points -n in=lines out=line_nodes'
>
> .... then 'v.distance from=gps to=line_nodes' + v.patch + v.clean ...
>
>
> Hamish
>
>
>
>>> 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