Skip to main content
Question

Detect direction of slope from contour lines


aron
Supporter
Forum|alt.badge.img+16
  • Supporter

I am trying to build height labels for contour lines from the lines themselves. This is pretty straightforward since the height values are contained in the contour data and I can easily extract them with the Labeller.

The problem is that I want all the height labels to be rotated as if one was always reading them facing uphill. They currently come out of the Labeller facing both uphill and downhill. The labels follow the contour line as they should, all that is fine, my only issue is that I want to rotate some of them 180 degrees.

How can I use the neighbouring contour lines to detect what is uphill?

What is the best way to rotate the eronous labels based on the above direction?

3 replies

takashi
Evangelist
  • January 30, 2018

Hi @aron, if the left hand side of a contour line was higher than the line, labels would be created with desired orientation, I think. If the logic was correct, this approach could be a solution.

  1. Add unique ID to every contour line (Counter).
  2. Create points at left hand side for each contour line (e.g. OffsetCurveGenerator + Snipper).
  3. Drape (i.e. add z-coordinate to) the points by the contour lines (SurfaceDraper).
  4. Extract z-coordinate from the point, then merge it to corresponding contour line, using the unique ID as join key (CoordinateExtractor or ElevationExtractor + FeatureMerger).
  5. If the z-coordinate is lower than elevation of the contour line, reverse its orientation (Tester + Orientor).

aron
Supporter
Forum|alt.badge.img+16
  • Author
  • Supporter
  • January 31, 2018

Hi @takashi

 

I tried something on my own before I saw your reply, and would like so see if I can get it working before I try something new.

What I did was use the Neigbourfinder to pick the closest contour line and extract its height value. In the next step I plan to use this to detect if the neighbouring contour is higher or lower than the label I want to create. This transformer also produces rotation of my point, rotation of the neighbouring contour line and the angle between them.

What is causing me headaches is calculating a heading/bearing that works in all possible combinations.

Any suggestions of how I can make my sorting hat (aka testfilter) do some magic?

Below is an example where the 700 and 900 labels are facing the wrong direction, they need to be flipped. The 600 label is looking just fine.


jdh
Contributor
Forum|alt.badge.img+28
  • Contributor
  • January 31, 2018

@aron

I would try something along the lines of

  1. Get the nearest adjacent contour (NeighborFinder)
  2. Determine which side it is on (LeftRightSpatialCalculator)
  3. Test to see if the contour is higher on the left or lower on the right (Tester)*
  4. If fail test 3, flip the orientation on the contour (Orientor)

*I may have these backwards, double check to confirm which combination of sidedness and slope yields the correct label orientation


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