Skip to main content

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?

How is the direction specified?

 

 


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.


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.

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


How is the direction specified?

 

 

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

 

 


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

For example


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.

 


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))))))

 


Reply