Solved

Local bearing along a line


Badge +22
  • Contributor
  • 1963 replies

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.

icon

Best answer by gio 9 December 2015, 12:23

View original

12 replies

Badge +7

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.

Badge +3

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

Badge +22

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.

Badge +22

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.

Badge +7

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

Badge

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

Badge

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

Badge +3

@johnm

Hi, sure.

It's still on my machine.

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

Have fun.

Badge

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.

Badge +3

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.

 

 

Badge

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

createarrow.fmw

Badge +3

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.

Reply