Skip to main content
Solved

Smooth line keeping vertex positions


btl
Contributor
Forum|alt.badge.img+3
  • Contributor

Is there a way to smooth a line so the resulting line passes through all the original vertices?

Best answer by david_r

Based on your feedback, I'm starting to think that there's no current transformer in FME that can smooth a polyline while preserving the vertices.

However, it should be fairly simple to implement in Python, see this example:

https://stackoverflow.com/a/14348309

Maybe the scipy.interpolate.spline() drawn in red is approaching what you want? (Hint: scipy.interpolate is already installed in the Python interpreter that comes with ArcGIS)

If you do end up implementing this, it would me much appreciated if you would share it through the FME Hub :-)

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

11 replies

david_r
Celebrity
  • July 12, 2018

Have you looked at any of the smoothing algorithms in the Generalizer transformer?


btl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • July 12, 2018
david_r wrote:

Have you looked at any of the smoothing algorithms in the Generalizer transformer?

Yes, McMaster and McMaster weighted seem to make big changes to the lines - they move completely away from their original path - to be honest I've read the documentation and I don't really understand what the algorithm or parameters do but I had a little play with them and didn't get any closer to what I want.

 

 

NURBfit produces a nice looking line but it looks like it goes tangentially through the mid-point of the original line segments.

 

 


david_r
Celebrity
  • July 12, 2018
btl wrote:
Yes, McMaster and McMaster weighted seem to make big changes to the lines - they move completely away from their original path - to be honest I've read the documentation and I don't really understand what the algorithm or parameters do but I had a little play with them and didn't get any closer to what I want.

 

 

NURBfit produces a nice looking line but it looks like it goes tangentially through the mid-point of the original line segments.

 

 

I just had a look, you're right about that. Hopefully someone else has any ideas.

jneujens
Forum|alt.badge.img
  • July 12, 2018

Simplifying a line always means you loose vertices, no?. Are these lines arcs? Or simple polylines?


btl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • July 12, 2018
jneujens wrote:

Simplifying a line always means you loose vertices, no?. Are these lines arcs? Or simple polylines?

No, I believe what I want is a bezier curve - there's a smoothing algorithm in Arc, haven't tested it because I want to do the whole process in FME if possible, but it looks like what I want (http://pro.arcgis.com/en/pro-app/tool-reference/cartography/smooth-line.htm).

 

 

My input is polylines.

 

 


verdoodtdries
Supporter
Forum|alt.badge.img+18

The algorithms of the Generalizer transformer are the proper way as david_r suggested.

Another way is to remove vertices by a combination of the VertexCounter and VertexRemover transformers.

If you want to develop your own smoothing algorithm, you can make use of the Python FME API inside a PythonCaller transformer.


david_r
Celebrity
  • Best Answer
  • July 12, 2018

Based on your feedback, I'm starting to think that there's no current transformer in FME that can smooth a polyline while preserving the vertices.

However, it should be fairly simple to implement in Python, see this example:

https://stackoverflow.com/a/14348309

Maybe the scipy.interpolate.spline() drawn in red is approaching what you want? (Hint: scipy.interpolate is already installed in the Python interpreter that comes with ArcGIS)

If you do end up implementing this, it would me much appreciated if you would share it through the FME Hub :-)


xiaomengatsafe
Safer
Forum|alt.badge.img+3

Hi @btl, It does look like we don't currently have a way to do this in FME, unless you can try david_r's python approach. So I made a suggestion on our Idea page, on your behalf. Can you please add any additional thoughts or use cases in there, and give it an up vote? We will take the popularity of these ideas into consideration, when they plan future development. :)


btl
Contributor
Forum|alt.badge.img+3
  • Author
  • Contributor
  • July 13, 2018
david_r wrote:

Based on your feedback, I'm starting to think that there's no current transformer in FME that can smooth a polyline while preserving the vertices.

However, it should be fairly simple to implement in Python, see this example:

https://stackoverflow.com/a/14348309

Maybe the scipy.interpolate.spline() drawn in red is approaching what you want? (Hint: scipy.interpolate is already installed in the Python interpreter that comes with ArcGIS)

If you do end up implementing this, it would me much appreciated if you would share it through the FME Hub :-)

I will have a go - Python in FME will be a new skill.

 

Thanks.

 

 


david_r
Celebrity
  • July 13, 2018
btl wrote:
I will have a go - Python in FME will be a new skill.

 

Thanks.

 

 

Excellent. Feel free to post any questions on the forum here.

xiaomengatsafe
Safer
Forum|alt.badge.img+3
xiaomengatsafe wrote:

Hi @btl, It does look like we don't currently have a way to do this in FME, unless you can try david_r's python approach. So I made a suggestion on our Idea page, on your behalf. Can you please add any additional thoughts or use cases in there, and give it an up vote? We will take the popularity of these ideas into consideration, when they plan future development. :)

Sorry @btl, I forgot to add the link to the idea. The comment above is edited with the hyperlink.

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