Skip to main content
Solved

Create Line from Point and Point Heading


I have a collection of points and for each point a heading is recorded. What I want to do is create lines for a specified distance (say 20 meters) in the direction of the heading recorded for each point. The start point will be the X/Y of the point.

Does anyone have any ideas on how to get started with this?

Best answer by ebygomm

You'll need to do a bit of work to the heading to use the rotator

For example

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

8 replies

takashi
Influencer
  • April 27, 2017
How is the direction specified?

 

 


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • April 27, 2017

I've done similar things in the past with a bit of trigonometry.

 

Basically add a VertexCreator in add point mode with the X value being the X0 + Distance*cos(Angle)

 

and the Y value being Y0 + Distance*sin(Angle).

 

 

where the Angle is in radians and measured counterclockwise from the positive x axis. (East)

 

 

if your heading is measured clockwise from the positive y axis (North) ie azimuth, you will need to convert using the formula

angle =mod(450?azimuth, 360) and then convert degrees to radians.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • April 27, 2017
jdh wrote:

I've done similar things in the past with a bit of trigonometry.

 

Basically add a VertexCreator in add point mode with the X value being the X0 + Distance*cos(Angle)

 

and the Y value being Y0 + Distance*sin(Angle).

 

 

where the Angle is in radians and measured counterclockwise from the positive x axis. (East)

 

 

if your heading is measured clockwise from the positive y axis (North) ie azimuth, you will need to convert using the formula

angle =mod(450?azimuth, 360) and then convert degrees to radians.

Note that this works best in a cartesian coordinate system. If you are working in lat/long over large distances, the math becomes more complicated and involves the law of haversine.

ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • April 27, 2017

I would create the line using the vertex creator to add 20m to the y coordinate and then rotate (presuming your heading is set in degrees) using the original x y as the origin


  • Author
  • April 27, 2017
takashi wrote:
How is the direction specified?

 

 

The direction is specified as azimuth(from -180 to 180)

 

 


ebygomm
Influencer
Forum|alt.badge.img+38
  • Influencer
  • Best Answer
  • April 27, 2017

You'll need to do a bit of work to the heading to use the rotator

For example


takashi
Influencer
  • April 27, 2017
If the direction is specified by an angle (azimuth), the excellent solutions provided by @jdh and @egomm can be applied. I would try @egomm's approach with this workflow.

 


geomancer
Evangelist
Forum|alt.badge.img+48
  • Evangelist
  • October 21, 2020

A different approach: 

You can also accomplish this using only a GeometryReplacer, with some trigonometry thrown in to build a WKT string (Well Known Text).

Point_to_Line_Geometry_ReplacerThe Geometry Source field contains this formula:

LINESTRING (@XValue() @YValue(), @Evaluate(@XValue() + (@Value(Distance) * sin(@degToRad(@Value(Azimuth))))) @Evaluate(@YValue() + (@Value(Distance) * cos(@degToRad(@Value(Azimuth))))))

 


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