Skip to main content
Solved

Make line based on distance from single point, and change direction


Forum|alt.badge.img+1

Hi. I want to make a line from a single point (based on distance in meter), and then change the direction.

 

I want to do this for multiple point. I have the line length, x and y coordinates, and line direction.

 

Line have to start from x and y point.

 

I'm using FME 2015.

 

 

Thanks.

Best answer by takashi

Assuming that each feature has four attributes - (x, y) of the first point, length of the line, and angle representing the line direction. An easy way is:

  1. VertexCreator (Mode: Replace with Point): Create a point (x, y).
  2. VertexCreator (Mode: Add Point): Add a point (x + length, y) to the first point to form a horizontal line with specified length.
  3. Rotator: Rotate the line around the first point (x, y) by specified direction (angle in degrees).
View original
Did this help you find an answer to your question?

8 replies

Forum|alt.badge.img+2

Hi @johsflesj

I'm not sure what the best way to do this would be but I think you may have to go about this in a slightly different way - instead of creating a line and changing the direction I think the best option would be to create the end point first. You can do this by extracting the point coordinates and then using the arithmetic editor, create a second point by adding a distance value to x and y (-/+ will put this point in the right direction) and from there you can join the two together to build your lines.

What is your line direction attribute recorded in? If you know the line length and direction I think it should be possible to work out what values you need to change your original point from.


Forum|alt.badge.img+2
hollyatsafe wrote:

Hi @johsflesj

I'm not sure what the best way to do this would be but I think you may have to go about this in a slightly different way - instead of creating a line and changing the direction I think the best option would be to create the end point first. You can do this by extracting the point coordinates and then using the arithmetic editor, create a second point by adding a distance value to x and y (-/+ will put this point in the right direction) and from there you can join the two together to build your lines.

What is your line direction attribute recorded in? If you know the line length and direction I think it should be possible to work out what values you need to change your original point from.

In fact using the VertexCreator a line will automatically be created for you if you use the arithmetic editor and input x/y +/- these new distances. So the only hurdle here is calculating the values to add to x and y - finally school maths might actually come in handy!

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • July 11, 2018

Attached in an old custom transformer, since the last save version is 2014, it should be okay on 2015.

 

 

pointfrombearing.fmx

 

 

Note that this only really works in Cartesian coordinates. If you are in lat/long and covering large distances, you need to use a more complicated equation.

Forum|alt.badge.img+1
  • Author
  • July 12, 2018
hollyatsafe wrote:

Hi @johsflesj

I'm not sure what the best way to do this would be but I think you may have to go about this in a slightly different way - instead of creating a line and changing the direction I think the best option would be to create the end point first. You can do this by extracting the point coordinates and then using the arithmetic editor, create a second point by adding a distance value to x and y (-/+ will put this point in the right direction) and from there you can join the two together to build your lines.

What is your line direction attribute recorded in? If you know the line length and direction I think it should be possible to work out what values you need to change your original point from.

Thanks for answering. The direction is recorded in degrees.

 

 


takashi
Influencer
  • Best Answer
  • July 12, 2018

Assuming that each feature has four attributes - (x, y) of the first point, length of the line, and angle representing the line direction. An easy way is:

  1. VertexCreator (Mode: Replace with Point): Create a point (x, y).
  2. VertexCreator (Mode: Add Point): Add a point (x + length, y) to the first point to form a horizontal line with specified length.
  3. Rotator: Rotate the line around the first point (x, y) by specified direction (angle in degrees).

Forum|alt.badge.img+1
  • Author
  • July 12, 2018
takashi wrote:

Assuming that each feature has four attributes - (x, y) of the first point, length of the line, and angle representing the line direction. An easy way is:

  1. VertexCreator (Mode: Replace with Point): Create a point (x, y).
  2. VertexCreator (Mode: Add Point): Add a point (x + length, y) to the first point to form a horizontal line with specified length.
  3. Rotator: Rotate the line around the first point (x, y) by specified direction (angle in degrees).
This way worked perfectly. Thank you so much!

 

Here is what i did:

 

 


Forum|alt.badge.img+1
  • Author
  • July 12, 2018
takashi wrote:

Assuming that each feature has four attributes - (x, y) of the first point, length of the line, and angle representing the line direction. An easy way is:

  1. VertexCreator (Mode: Replace with Point): Create a point (x, y).
  2. VertexCreator (Mode: Add Point): Add a point (x + length, y) to the first point to form a horizontal line with specified length.
  3. Rotator: Rotate the line around the first point (x, y) by specified direction (angle in degrees).
Can some please explain me why VertexCreator (Add point) creates a line?

Forum|alt.badge.img+1
  • Author
  • July 12, 2018

So, I made the data doing this:

 

The problem now is that only a few lines got the right direction. Most are pointing eastwards, when the direction deegree is for example 10 or 359.

 

 

Does anyone know?

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