# Prevent two lines from connecting to one point

Hello.
After dividing the points into equal parts on the road outline, I created a line connected to the nearest point. Since then, I have been working on making a center point on the connected line to make the center line of the road and then connecting it.

While I was working on connecting the lines to the nearest point, there was a situation where several lines were connected to the same point as shown in the picture below.

If anyone knows how to make sure that only one line is connected to one point, Iâ€™d like to ask for help.

Iâ€™m attaching the Rhino file and the grashopper file below, so Iâ€™d appreciate it if you could refer to it and help me.
Connecting closest point.3dm (4.0 MB)
closest point.gh (15.7 KB)

In some other places it seems it would be correct to have two lines connecting to the same point:

If not, please explain why and how.
What are those lines?
How you generated the points? Manually?

The method of creating the points was created by setting the interval using the Divide Length component.

As you said, the lines created in the four places you marked are connected to the correct line I need.

If I want to save the lines in that marked area, Shouldnâ€™t use the method of not connecting multiple lines to same point. Thank you for finding it.

If you have any solutions to this situation, I would appreciate it if you could tell me.

I donâ€™t have solutions because I donâ€™t know what you are trying to do.
â€ślinesâ€ť is generic.
Why you need those lines?
What are those lines?
How will you used them, then?

Iâ€™m doing this to make points marked with navy circles, to figure out the center point of the road, and then to draw the center line of the road by connecting the line like the green line.

Previously, it was done manually, so I thought that creating an algorithm to automate it with a grashopper would improve work efficiency.

Even if you managed to make the lines, then you would need to sort those lines, another hard task without proper topology or sorted starting data.

Imo, try to firstly close your input curves, fix all gaps.
Closed curves would at least give â€śregionsâ€ť of what is the road and what is not-the-road:

then, this task is still hard:
see Extract Centreline of polylines - #6 by laurent_delrieu
or
Old Town Roofs - #44 by laurent_delrieu

From this image it is possible to extract center lines

With my Nautilus plugin or

Image Thinner 2
Draw a 1 pixel wide skeleton of an image while retaining the shape and structure of the full image. It uses the Zhang-Suen Thinning Algorithm from third method in image - Zhang-Suen thinning algorithm C# - Stack Overflow

center line.gh (1.7 MB)

1 Like

Old cheap hack with voronoi:

shape rough centerline.gh (16.1 KB)

This is a difficult task and already discussed here and then in the forum, try to search more.

I donâ€™t remember an exhaustive solution.

This seems a common task for handling satellite data or city mapsâ€¦?
A good and reliable algorithm would probably be sold or made a specific softwareâ€¦ maybe?

3 Likes

thatâ€™s beautiful, never seen before it just made my brain explode

Me too.

Brilliant To clarify in simple words, this code culls Voronoi lines that donâ€™t have both end points on the â€śroadâ€ť surface?

1 Like

Yeah, just that.

Another step would join whatâ€™s left and split at â€śYâ€ť joints. Then culling again by lenght or by distance from outer border.

1 Like

great use of booleans