[GRASS-user] v.dissolve for lines?

Markus Metz markus.metz.giswork at googlemail.com
Wed Oct 20 05:39:55 EDT 2010


Micha Silver wrote:
>  On 20/10/2010 08:36, Markus Metz wrote:
>>
>> Micha Silver wrote:
>>>
>>> Bryan Keith wrote:
>>>>
>>>> Hello,
>>>>
>>>> I have a vector line file that has lots of two-vertex lines.  Many of
>>>> these two-vertex lines share endpoints and really just make parts of one
>>>> longer line.  I'd like to dissolve these lines into one line when they
>>>> have the same end point.  It looks like v.dissolve only works for areas.
>>>> Is there somewhere else I should be looking?  Thank you.
>>>>
>>>>
>>> Did you have a look at v.build.polylines ?
>>> Additional note: line vectors have a direction. Two line segments with an
>>> equivalent node (end point) will *not* connect if they are in opposite
>>> directions.
>>
>> Each line has two nodes, one at the start and one at the end. If at
>> the end of one line any other line is starting or ending, this other
>> line is added to the first line, reversing the direction if necessary.
>> IOW, two lines with a common node will indeed connect, and the
>> direction of one line may need to be reversed (done automatically).
>> Very simple to test by digitizing a simple test vector.
>>
> Heh, thanks for the correction!
> Was this always the case? I seem to remember not be able to merge lines
> unless they were connected in the same direction.
> How does the line reversal work? That is, Which of the two line segments is
> chosen be get reversed?

v.build.polyline works as follows:
it picks a line and from its start node, walks back as long as exactly
one other line is connected to this node. Line directions are reversed
as required, i.e. it does not matter if the next line is connected to
the current node by its start or end node.

Once the start line of a polyline is identified, it walks forward and
adds all vertices (in reverse order if needed) of connected lines to
the start line, i.e. the start line and connecting lines are reversed
as needed. That is, if a line is reversed depends on what node is
initially picked for building polylines.

If the direction of lines is important (it's not for boundaries to
build areas), you have to manually change line directions with either
v.edit or the wxdigitizer or the tool by Maris.

Markus M

> Regards,
> Micha
>
>> In this case you can try the v.edit tool=flip option (on those
>>>
>>> segments only)
>>
>> Should not be needed as pre-processing step for v.build.polylines.
>>
>>
>> Markus M
>>
>> This mail was received via Mail-SeCure System.
>>
>>
>
>
> --
> Micha Silver
> http://www.surfaces.co.il/
> Arava Development Co.  +972-52-3665918
>
>


More information about the grass-user mailing list