Skip to main content

I have a table of linear sections, each with a unique SectionID. Each section has From XYs, and To XYs. There is anywhere from 1 to N points between from and to, depending on the section.

 

Right now, each row represents one of these "in-between" points, with a SequencenNumber attribute saying what order they appear in.

 

My goal is to create 2 additional rows per SectionID. One that is sequence 0, and populates the regular X and Y fields with the From XY values. Another that is sequence N, where N is the highest occuring sequence number, plus 1, that populates the regular X and Y fields with the To XY values. I can re-order them afterwards with Sorter if need be, but they need to be in order both by sectionID and sequentially so that LineBuilder draws them properly. I know I can group by SectionID in LineBuilder as well.

 

I'm a bit of an FME noob, so any help would be appreciated! I really can't think of what transformer or workflow to use to make this happen!

I'm not exactly sure on what you need, but one approach could be with an AttributeCreator, under the dropdown at the top you can enable adjacent feature handling. This allows you to create conditional logic based on what the previous feature or next feature is. So you can detect which feature is the last in a section when the feature(+1).SectionID doesn't equal the feature's own SectionID, and create an attribute based on that, and then duplicate that 'last' feature.

 

It also sounds like though for each row you could use two VertexCreators, Add Point for the FromXY, then Add Point again for the ToXY (creating a line), then use a LineCombiner to combine them all together.


I'm not exactly sure on what you need, but one approach could be with an AttributeCreator, under the dropdown at the top you can enable adjacent feature handling. This allows you to create conditional logic based on what the previous feature or next feature is. So you can detect which feature is the last in a section when the feature(+1).SectionID doesn't equal the feature's own SectionID, and create an attribute based on that, and then duplicate that 'last' feature.

 

It also sounds like though for each row you could use two VertexCreators, Add Point for the FromXY, then Add Point again for the ToXY (creating a line), then use a LineCombiner to combine them all together.

Sorry, should have attached some screencaps to assist.

Attribute creator, especially with adjacent feature handling, seems like a winner. But I'm still not sure how to actually create the new feature.

 

The only thing missing from the screencap is a list exploder coming off the merged values to turn the list back into a traditional attribute table.


I'm not exactly sure on what you need, but one approach could be with an AttributeCreator, under the dropdown at the top you can enable adjacent feature handling. This allows you to create conditional logic based on what the previous feature or next feature is. So you can detect which feature is the last in a section when the feature(+1).SectionID doesn't equal the feature's own SectionID, and create an attribute based on that, and then duplicate that 'last' feature.

 

It also sounds like though for each row you could use two VertexCreators, Add Point for the FromXY, then Add Point again for the ToXY (creating a line), then use a LineCombiner to combine them all together.

And here is the table of values


Thanks, the data helps. What I had suggested with using adjacent features on an AttributeCreator would work, but this is easier. There's lots of ways to solve the same problem with FME.

image 

I think the technique you're missing is that you can output more than one branch from a transformer port, making features go out both branches.

Then, because each section in your table has the same From/To X/Y on each row, you can use an aggregator to group them together to get a single feature for each section which has the X and Y for each end of the line. Branch it again, set one branch to be SequenceNumber -1 and, and the other to be 9999, then create the vertexes as you would, and sort them to the right order, create the line.

 


This is AWESOME! A huge help - thank you so much!

I set it up exactly as you have it, but I'm getting an error with the vertex creator. The From XYs and To XYs created in the AttributeCreators are coming out as rejected features, saying they have invalid geometries. Any ideas?


This is AWESOME! A huge help - thank you so much!

I set it up exactly as you have it, but I'm getting an error with the vertex creator. The From XYs and To XYs created in the AttributeCreators are coming out as rejected features, saying they have invalid geometries. Any ideas?

The VertexCreator will typically only reject if the X or Y value it was supplied was null. I also assumed that that screenshot of data table has no geometry at that point. AttributeCreator_2 there should be overwriting the X and Y attributes for each first row with the FromX and FromY values, so check if the features out of it have valid X and Y attributes. You only need one VertexCreator in total, adding from the X and Y attribute.


The VertexCreator will typically only reject if the X or Y value it was supplied was null. I also assumed that that screenshot of data table has no geometry at that point. AttributeCreator_2 there should be overwriting the X and Y attributes for each first row with the FromX and FromY values, so check if the features out of it have valid X and Y attributes. You only need one VertexCreator in total, adding from the X and Y attribute.

verified that the X and Y populated correctly (or at least I think they did). I inspected the attribute creator results and they looked correct to me. I'll need to dig into this with co-workers tomorrow.

 

Thanks again for your help! This was VERY useful!


Reply