Skip to main content
Question

How to trim lines with multiple ends to get only the "best"/longest line?


Hi! I got several lines made of polygons with the CenterLineReplacer (medial axis), but i only want to keep the longest line with only two ends of each line. Is there a way for that?

In the picture below you can first see the line with several ends, in the second picture you see the line as it should look.

 

Thank you in advance!

3 replies

jovitaatsafe
Safer
Forum|alt.badge.img+11

HI @bastianr95,

is this feature all one line? I have a few ideas for you, depending on how many vertices are in those spikes, you could try a SpikeRemover such as in this article example.

 

 

Or else if those extra ends have overlapping/duplicate vertices, you could consider removing those vertexes using a VertexRemover.

Lastly if the first two didn't do it, and the longest method: you could try an Intersector to set Split Self-Intersecting Features to Yes and Aggregate Handling to Deaggregate. You could then filter out the tiny extra lines based on a LengthCalculator and Tester on length. Something like a LineCombiner could then put your lines back together.

Hope one of these helps!


  • Author
  • June 25, 2020
jovitaatsafe wrote:

HI @bastianr95,

is this feature all one line? I have a few ideas for you, depending on how many vertices are in those spikes, you could try a SpikeRemover such as in this article example.

 

 

Or else if those extra ends have overlapping/duplicate vertices, you could consider removing those vertexes using a VertexRemover.

Lastly if the first two didn't do it, and the longest method: you could try an Intersector to set Split Self-Intersecting Features to Yes and Aggregate Handling to Deaggregate. You could then filter out the tiny extra lines based on a LengthCalculator and Tester on length. Something like a LineCombiner could then put your lines back together.

Hope one of these helps!

Hi,

thanks for your answer. The problem is: i have a large number of lines. The intersector approach works at least a little, but there are also a few cases where the ends that are to be deleted are much longer than lines that are not should be deleted. But i think its the only way how i can solve the problem at least a little bit.


Forum|alt.badge.img+2

Length calculator, statistic calculator for length with max checked and grouped by the polygon ID, tester with max = length. That will give you only the longest line.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings