Solved

Cutting lines into separate segments with their own attribute


Hi, I have a CSV file with 20 spatial points & I was able to convert the points into a line (using LineBuilder) but the line which is created is having a single feature to it. I have used Chopper Transformer to cut the line. It does the job for cutting the lines but all features get same as the first one feature.

How I can separate the feature as well with the lines

Please Help ..!

icon

Best answer by geomancer 13 August 2021, 09:02

View original

11 replies

Userlevel 3
Badge +33

You can create lines from the input points, where the second point gets the coordinates of the next feature.

You can realise this by first adding the coordinates of the next feature to a point (using an AttributeManager with 'Enable Adjacent Feature Attributes'), and then adding a vertex to the point, using these coordinates, thus creating a line.

Point2Linein the attached workspace the CSV file contains attributes called X and Y, which FME 'automagically' recognises as coordinates. And of course the last point has to be treated different, as it has no next feature.

Badge +4

Does your CSV data have a field that indicates which points belong to which lines? (ie. Line1, Line2, etc.) If so, you can Group By this field in the LineBuilder, and it will output separate lines.

 

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/linebuilder.htm?Highlight=linebuilder

 

You can create lines from the input points, where the second point gets the coordinates of the next feature.

You can realise this by first adding the coordinates of the next feature to a point (using an AttributeManager with 'Enable Adjacent Feature Attributes'), and then adding a vertex to the point, using these coordinates, thus creating a line.

Point2Linein the attached workspace the CSV file contains attributes called X and Y, which FME 'automagically' recognises as coordinates. And of course the last point has to be treated different, as it has no next feature.

image3image2image 2 above.

 

I have this data set as shown in image1.

& after transformation I am getting this image2.

image 3 FME work bench.

Can u help me in this.

 

image1

image1 

Userlevel 3
Badge +33

You can create lines from the input points, where the second point gets the coordinates of the next feature.

You can realise this by first adding the coordinates of the next feature to a point (using an AttributeManager with 'Enable Adjacent Feature Attributes'), and then adding a vertex to the point, using these coordinates, thus creating a line.

Point2Linein the attached workspace the CSV file contains attributes called X and Y, which FME 'automagically' recognises as coordinates. And of course the last point has to be treated different, as it has no next feature.

Passing your (visible) point data through a modified version of my workspace (see attachment) I get the following results:

Point2Line_v2

Passing your (visible) point data through a modified version of my workspace (see attachment) I get the following results:

Point2Line_v2

Thanks this works 😊 .

I was just trying it in different way like adding a counter to it & giving it a unique id to it & then passing it through the vertex creator (Mode ->Replace with Points) then create a line from with their specified ids but I am ending up 1st attribute to all other.

Does your CSV data have a field that indicates which points belong to which lines? (ie. Line1, Line2, etc.) If so, you can Group By this field in the LineBuilder, and it will output separate lines.

 

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/linebuilder.htm?Highlight=linebuilder

 

I have used counter to generate unique ids to it & then pass it through vertex creator & in line builder when ever I use Group By this field I wont get any output.

Userlevel 3
Badge +33

Does your CSV data have a field that indicates which points belong to which lines? (ie. Line1, Line2, etc.) If so, you can Group By this field in the LineBuilder, and it will output separate lines.

 

https://docs.safe.com/fme/html/FME_Desktop_Documentation/FME_Transformers/Transformers/linebuilder.htm?Highlight=linebuilder

 

A solution using 2 LineBuilders in parallel with GroupBy:

Point2Line_v3

A solution using 2 LineBuilders in parallel with GroupBy:

Point2Line_v3

CaptureNow I have above work flow & no I want to connect all the points I have tried with Line Builder I getting single output. Can you please me in this

Userlevel 3
Badge +33

A solution using 2 LineBuilders in parallel with GroupBy:

Point2Line_v3

Add the steps from either of my workspaces (VertexCreator in Add Point mode, or LineBuilder, in both cases using appropriate attributes you have created before) and you will get line objects between two adjacent points.

And undoubtedly there are other ways to create the line objects. Try and learn!

Passing your (visible) point data through a modified version of my workspace (see attachment) I get the following results:

Point2Line_v2

Hi @geomancer​ I was having doubt in Point2Line_v2.

how you have created line between two pts without using the any line builder transformer?

Userlevel 3
Badge +33

Passing your (visible) point data through a modified version of my workspace (see attachment) I get the following results:

Point2Line_v2

Hi @rohan98​ , the VertexCreator changes point features into line features when in Add Point mode.

To make this work, I first added to each feature the coordinates of the next feature as attributes in the AttributeManager, by utilizing the Enable Adjacent Feature Attributes setting, looking forward to the next ('subsequent') feature.

Reply