Skip to main content
Solved

Local bearing along a line


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor

Suggestions for an efficient way to determine the local bearing of an arbitrary location along a line. Local bearing is the azimuth angle of a given point to the next vertex in the line.

Bonus points if it iterates easily.

Best answer by gio

Hi,

Like this?

1. Use chopper on polyline.

2. extract start and end vertices, and name them accordingly. I used S_x,S_y\\

and E_x,E_y.

3. calculate angle.

4. vertexcereator replace mode for startpoints.

5. vertexcreator with following vlaues

x= @Value(S_x)+@Evaluate(@Value(OFFSET)*@cos((@Value(Hoek_)/180)*$(Pi)))

y= @Value(S_y)+@Evaluate(@Value(OFFSET)*@sin((@Value(Hoek_)/180)*$(Pi)))

Offset variable i created to give lenght to a "bearingpointer" (arrow/vector)

Set lenght to you desire.

Now u got your bearing.

(nb. if you use Azimuthcalculator you wont need to extracxt endcoordinates.)

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

12 replies

roland.martin
Forum|alt.badge.img+9

Hi,

If I've understood correctly, you want to split the line into 2-vertex segments (Splitter set at 2 vertices) and then use this custom transformer to get the angle. If you wish to assign the result back to the first point in each line segment, use a CoordinateExtractor to extract vertex 0, followed by a VertexCreator replacing the line with a point.

r.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • Best Answer
  • December 9, 2015

Hi,

Like this?

1. Use chopper on polyline.

2. extract start and end vertices, and name them accordingly. I used S_x,S_y\\

and E_x,E_y.

3. calculate angle.

4. vertexcereator replace mode for startpoints.

5. vertexcreator with following vlaues

x= @Value(S_x)+@Evaluate(@Value(OFFSET)*@cos((@Value(Hoek_)/180)*$(Pi)))

y= @Value(S_y)+@Evaluate(@Value(OFFSET)*@sin((@Value(Hoek_)/180)*$(Pi)))

Offset variable i created to give lenght to a "bearingpointer" (arrow/vector)

Set lenght to you desire.

Now u got your bearing.

(nb. if you use Azimuthcalculator you wont need to extracxt endcoordinates.)


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • December 9, 2015
roland.martin wrote:

Hi,

If I've understood correctly, you want to split the line into 2-vertex segments (Splitter set at 2 vertices) and then use this custom transformer to get the angle. If you wish to assign the result back to the first point in each line segment, use a CoordinateExtractor to extract vertex 0, followed by a VertexCreator replacing the line with a point.

r.

I don't want the bearing at every vertex, but rather at specific points along the line, which may or may not correspond to an existing vertex.


jdh
Contributor
Forum|alt.badge.img+28
  • Author
  • Contributor
  • December 9, 2015
gio wrote:

Hi,

Like this?

1. Use chopper on polyline.

2. extract start and end vertices, and name them accordingly. I used S_x,S_y\\

and E_x,E_y.

3. calculate angle.

4. vertexcereator replace mode for startpoints.

5. vertexcreator with following vlaues

x= @Value(S_x)+@Evaluate(@Value(OFFSET)*@cos((@Value(Hoek_)/180)*$(Pi)))

y= @Value(S_y)+@Evaluate(@Value(OFFSET)*@sin((@Value(Hoek_)/180)*$(Pi)))

Offset variable i created to give lenght to a "bearingpointer" (arrow/vector)

Set lenght to you desire.

Now u got your bearing.

(nb. if you use Azimuthcalculator you wont need to extracxt endcoordinates.)

This gives me some ideas for a starting place. Thanks.


roland.martin
Forum|alt.badge.img+9
jdh wrote:

I don't want the bearing at every vertex, but rather at specific points along the line, which may or may not correspond to an existing vertex.

Sorry, I missed that.

OK, start by splitting the line at the points - there are various transformers that do this, but the simplest is probably PointOnLineOverlayer. So:

  1. Add a counter to your points, so you have a unique ID
  2. PointOnLineOverlayer
  3. AzimuthCalculator
  4. FeatureMerger, to join your lines with azimuth back to the original points, based on the unique ID

I also meant Chopper rather than Splitter, but that's academic now...


Forum|alt.badge.img
  • September 8, 2018

Hi @gio Would you be able to share your fmw Workspace for this solution please?


Forum|alt.badge.img
  • September 8, 2018

Hi @gio , Would you be able to share your fmw Workspace for your solution please?


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 10, 2018

@johnm

Hi, sure.

It's still on my machine.

The arrow custom is more complex then the main though...linebearings.fmw

Have fun.


Forum|alt.badge.img
  • September 10, 2018

Hi @gio, Thanks for this, I would like you to have a look at the one I did to see what you think?

Will get back to you tomorrow with the fmw.


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 10, 2018
johnm wrote:

Hi @gio, Thanks for this, I would like you to have a look at the one I did to see what you think?

Will get back to you tomorrow with the fmw.

Sure, my pleasure.

 

 


Forum|alt.badge.img
  • September 11, 2018

Hi @gio, Here is another script (2016) for the arrow where the direction angle is provided. Cheers.

createarrow.fmw


gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • September 11, 2018
johnm wrote:

Hi @gio, Here is another script (2016) for the arrow where the direction angle is provided. Cheers.

createarrow.fmw

Hi @johnm

 

 

Tx.

 

 

 

My arrow creator is scaled by input (larger line => larger arrows. Also size of arrowhead, shaft etc. are variable.)

 

It takes input lines, points or just attributes.

 

I have tried to make it as flexible as possible. It has evolved a bit since I posted above script. Trying to get it to make all kinds of arrowheads.

 

 

The createarrow.fmw is fixed size and has hardcoded values.

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