Skip to main content
Solved

Change the start point of closed curve


ireen
Contributor
Forum|alt.badge.img+5
  • Contributor

Hello,

Is there a possibility to change the start/end point of closed curve?

I created closed curves using the LineCombiner (for merging line segments to 1 closed track with the same start and end point).

Now I have a shapefile with starting points of tracks, and I want the closed curves to start/end in their starting point instead of the random start/end that is created whith the LineCombiner.

Anyone an idea how to do this?

Best answer by takashi

Hi @ireen, this workflow might help you.

Step 1: Remove the last vertex from the closed line, get the number of vertices, decompose the line into individual vertices, and add 0-based vertex index to them.

0684Q00000ArKqhQAF.png

Step 2: Find the index of the vertex that spatially matches the given starting point, and then update every vertex index in the correct order that starts from the given point. 

0684Q00000ArL1rQAF.png

ExpressionEvaluator Parameters

  • Evaluation Mode: Overwrite Existing Attributes
  • Attributes To Overwrite: _vertex_index
  • Arithmetic Expression:
@CurrentAttribute()<@Value(_start_index) ? @Value(_coordcount)+(@CurrentAttribute()-@Value(_start_index)) : @CurrentAttribute()-@Value(_start_index)

Step 3: Re-construct closed line whose vertices have the correct order.

0684Q00000ArKslQAF.png

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

4 replies

takashi
Supporter
  • Best Answer
  • May 19, 2017

Hi @ireen, this workflow might help you.

Step 1: Remove the last vertex from the closed line, get the number of vertices, decompose the line into individual vertices, and add 0-based vertex index to them.

0684Q00000ArKqhQAF.png

Step 2: Find the index of the vertex that spatially matches the given starting point, and then update every vertex index in the correct order that starts from the given point. 

0684Q00000ArL1rQAF.png

ExpressionEvaluator Parameters

  • Evaluation Mode: Overwrite Existing Attributes
  • Attributes To Overwrite: _vertex_index
  • Arithmetic Expression:
@CurrentAttribute()<@Value(_start_index) ? @Value(_coordcount)+(@CurrentAttribute()-@Value(_start_index)) : @CurrentAttribute()-@Value(_start_index)

Step 3: Re-construct closed line whose vertices have the correct order.

0684Q00000ArKslQAF.png


ireen
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • May 20, 2017

I'll give this a try. Thanks for the input!


takashi
Supporter
  • May 20, 2017

If you would use a PythonCaller to modify the order of line vertices, the workflow could be more concise.

0684Q00000ArKteQAF.png

# PythonCaller Script Example
import fmeobjects
def changeStartVertexOfClosedLine(feature):
    v = feature.getAllCoordinates()[:-1]
    i = int(feature.getAttribute('_index'))
    feature.setGeometry(fmeobjects.FMELine(v[i:] + v[:i+1]))

hansgm
Contributor
Forum|alt.badge.img
  • Contributor
  • September 26, 2019

Hello

i have a problem with the LineCombiner too.

 

I have lines and arcs and they are sorted in the sequence like i need it.(Sorted with Attributes for line id and element number starting with 0), but the LineCombiner does not start with the first incoming element.

 

How can i force the LineCombiner to start with my first element?

 

Thanks


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