Solved

Create multiple Lines out of Points

  • 15 September 2020
  • 12 replies
  • 10 views

Hi,

I have a point data set and I want to connect all points that have the same ID to each other. So if four points have the same id, each point should create a line to the other three points. The LineBuilder does not solve my problem because it simply creates an entire line and not just individual ones. I've read a few articles that the VertexCreator could help me, but I haven't found the solution yet.

I would be very happy about your help. Greetings, Bastian

icon

Best answer by oscard 15 September 2020, 12:42

View original

12 replies

Userlevel 2
Badge +19

The LineBuilder with the GroupBy by that ID should do the trick.

 

EDIT: I think I misread your question. Do you mean that the first point with one ID has to create a line to each of the rest points with the same ID?

 

Userlevel 4

I'm not quite sure I understand about the LineBuilder, did you remember to set the Group By to the ID attribute? In earlier versions of FME this setting was also called Connection Break Attributes.

This should force a new line for each change in the ID. Just make sure that the points are arriving in the correct order (e.g. use a Sorter).

@oscard​ @david_r​ 

No, unfortunately not. I did that, but The LineBuilder then only creates one line. I put in 4 points with the same ID and only get one line with the ID out. But I need every possible line (with 4 points it would be 12 lines). But maybe i misunderstand something about the LineBuilder...

The LineBuilder with the GroupBy by that ID should do the trick.

 

EDIT: I think I misread your question. Do you mean that the first point with one ID has to create a line to each of the rest points with the same ID?

 

Yes, that's what i meant. And the other points with the same ID should do the same.

Userlevel 2
Badge +19

@oscard​ @david_r​ 

No, unfortunately not. I did that, but The LineBuilder then only creates one line. I put in 4 points with the same ID and only get one line with the ID out. But I need every possible line (with 4 points it would be 12 lines). But maybe i misunderstand something about the LineBuilder...

No. The LineBuilder won't get what you want. Right now I don't know how to solve your issue. I will give it a thought as soon as I have a little time off. Although by that time I bet someone else has posted a great soulution :)

Userlevel 2
Badge +19

I think I've got it:

 

p1

First use a CoordinateExtractor to get the X, Y and Z of every point. Then use a Counter to give each point a unique number.

 

In the Feature Merger, the Requestor and Supplier take the same input. Join them on your ID. Don't forget to generate a List with the attributes:

 

p2

Explode the list using the ListExploder. The Tester filters the point that has been merged with itself. The condition is:

p3

"_count" is the attribute created by the Counter.

The last step is using a VertexCreator:

p4

Let me know if this works for you.

Hello, thank you in advance. I'm more of an FME beginner and that's why I still have a little problem. For the tester you need both attributes in the ListExploder list, _count and _points__count. However, I only get the _count from the list. How can you get both attributes with the ListExploder in order to then test them in the tester? Thanks

 

Userlevel 2
Badge +19

Hello, thank you in advance. I'm more of an FME beginner and that's why I still have a little problem. For the tester you need both attributes in the ListExploder list, _count and _points__count. However, I only get the _count from the list. How can you get both attributes with the ListExploder in order to then test them in the tester? Thanks

 

In the FeatureMerger make sure you have the "_count" Attribute in the Selected Attributes of the Generate List section.

I think I've got it:

 

p1

First use a CoordinateExtractor to get the X, Y and Z of every point. Then use a Counter to give each point a unique number.

 

In the Feature Merger, the Requestor and Supplier take the same input. Join them on your ID. Don't forget to generate a List with the attributes:

 

p2

Explode the list using the ListExploder. The Tester filters the point that has been merged with itself. The condition is:

p3

"_count" is the attribute created by the Counter.

The last step is using a VertexCreator:

p4

Let me know if this works for you.

That worked perfectly, thanks a lot!

I think I've got it:

 

p1

First use a CoordinateExtractor to get the X, Y and Z of every point. Then use a Counter to give each point a unique number.

 

In the Feature Merger, the Requestor and Supplier take the same input. Join them on your ID. Don't forget to generate a List with the attributes:

 

p2

Explode the list using the ListExploder. The Tester filters the point that has been merged with itself. The condition is:

p3

"_count" is the attribute created by the Counter.

The last step is using a VertexCreator:

p4

Let me know if this works for you.

Hi Oscard

I can't seem to make this work. in the FeatureMerger I only get 1 merged

Hi Oscard

I can't seem to make this work. in the FeatureMerger I only get 1 merged

of course the second i reply, I solve it. grouped it by the "ID" also skipped the tester. that worked out for me for some reason :)

 

Userlevel 2
Badge +19

Hi Oscard

I can't seem to make this work. in the FeatureMerger I only get 1 merged

Hi.

Do they have a common ID? If you could share a sample of your data we could take a look.

 

EDIT: Sorry, I didn't see your latest answer. Glad you could make it work :)

Reply