Skip to main content
Solved

LineBuilder to make one line but separate features between each point

  • November 27, 2020
  • 8 replies
  • 97 views

I have a csv of locations points tracking a utility vehicle. Each point is denoted by the "POSITION" number, and they are grouped by a "TRIP" attribute. The LineBuilder transformer will either A) Make a single line connected all points or B) if I group by Position it will leave as points.

 

I've done this in Python by using a combination iteration, to use a for loop to connect each point to the one in front of it, but I am unsure what transformers I would use in FME. Additionally, I have yet to figure out how to access and output my features using the PythonCaller.

 

How would I go about connecting each point to the next individually?

Best answer by markatsafe

@barnard87​ OK with those new requirements you might find that using AttributeCreator and Adjacent Feature Attributes is a faster option. LineBuilder can be slow with a lot of data. The workspace could look something like:

workspaceThe trick is in the AttributeCreator:

transformerYou'll have to add a Sorter if the data isn't ordered correctly by TRIP, and POSITION

 

I've attached the example (FME 202.2)

View original
Did this help you find an answer to your question?

8 replies

Forum|alt.badge.img+2
  • November 28, 2020

@barnard87​  ensure your data is ordered by TRIP, and POSITION (Sorter). Then in the LineBuilder, set the Group By to TRIP. This will break the line whenever the value of TRIP changes.


  • Author
  • November 28, 2020
markatsafe wrote:

@barnard87​  ensure your data is ordered by TRIP, and POSITION (Sorter). Then in the LineBuilder, set the Group By to TRIP. This will break the line whenever the value of TRIP changes.

Hello there, thanks for the reply!

 

Unfortunately, this was my first attempt, which resulted in the output of just the point data. Let me try again and look if I missed anything!


  • Author
  • November 28, 2020
markatsafe wrote:

@barnard87​  ensure your data is ordered by TRIP, and POSITION (Sorter). Then in the LineBuilder, set the Group By to TRIP. This will break the line whenever the value of TRIP changes.

Hi there. I think the issue was in the phrasing of my question. If trip 7 has 14 points, all with unique position numbers, I still need a continuous line connecting all the positions together (which what you've said will do) , but it makes a single line feature, where I will need multiple line features (Line 1 to 2, 2 to 3, 3 to 4) etc all the way to 14.


geomancer
Evangelist
Forum|alt.badge.img+47
  • Evangelist
  • November 30, 2020
barnard87 wrote:

Hi there. I think the issue was in the phrasing of my question. If trip 7 has 14 points, all with unique position numbers, I still need a continuous line connecting all the positions together (which what you've said will do) , but it makes a single line feature, where I will need multiple line features (Line 1 to 2, 2 to 3, 3 to 4) etc all the way to 14.

Pass the results from the LineBuilder through a Chopper, with Mode set to 'By Vertex' and Maximum Vertices set to 2. Does this give you the results you want?


Forum|alt.badge.img+2
  • Best Answer
  • November 30, 2020

@barnard87​ OK with those new requirements you might find that using AttributeCreator and Adjacent Feature Attributes is a faster option. LineBuilder can be slow with a lot of data. The workspace could look something like:

workspaceThe trick is in the AttributeCreator:

transformerYou'll have to add a Sorter if the data isn't ordered correctly by TRIP, and POSITION

 

I've attached the example (FME 202.2)


  • Author
  • December 1, 2020
markatsafe wrote:

@barnard87​ OK with those new requirements you might find that using AttributeCreator and Adjacent Feature Attributes is a faster option. LineBuilder can be slow with a lot of data. The workspace could look something like:

workspaceThe trick is in the AttributeCreator:

transformerYou'll have to add a Sorter if the data isn't ordered correctly by TRIP, and POSITION

 

I've attached the example (FME 202.2)

Yes thank you, this adjacent feature attributes option was exactly what I needed to replicate combination iteration as I do in Python. I imagine I will merge the point features, and then draw lines from Position 10 -> Position 10(with _nextX and Y), and so on and so fourth.

 

My only remaining question is how do I specify a value for the last item? Since there is not feature[+1] after it.


  • Author
  • December 1, 2020
barnard87 wrote:

Yes thank you, this adjacent feature attributes option was exactly what I needed to replicate combination iteration as I do in Python. I imagine I will merge the point features, and then draw lines from Position 10 -> Position 10(with _nextX and Y), and so on and so fourth.

 

My only remaining question is how do I specify a value for the last item? Since there is not feature[+1] after it.

Actually, I see this created the line's already, I see how it operates now. Still, how would you go about handling the last feature? Potentially if the final point has some data in it that I need, I imagine I would merge any notes as a list attribute


ebygomm
Influencer
Forum|alt.badge.img+32
  • Influencer
  • December 1, 2020
barnard87 wrote:

Yes thank you, this adjacent feature attributes option was exactly what I needed to replicate combination iteration as I do in Python. I imagine I will merge the point features, and then draw lines from Position 10 -> Position 10(with _nextX and Y), and so on and so fourth.

 

My only remaining question is how do I specify a value for the last item? Since there is not feature[+1] after it.

If you want to create list attributes containing the data from the start and end point of each line you probably need a different approach e.g.

Capture


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