Skip to main content
Question

detect vertex changes in line

  • April 22, 2015
  • 5 replies
  • 163 views

zzupljanin
Contributor
Forum|alt.badge.img+5
So, I have .dgn data with waters of certain area. The problem lies in rivers since I want them to have descending elevation as river aproaches ocean or sea or other water body. Basically I'd like to test elevation of vertices of polyline of river so that it marks me those that are ascending in descending order. Any ideas?
This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

5 replies

nielsgerrits
VIP
Forum|alt.badge.img+66
Chopper (lines to vertices) & attributecreator (advanced / prior) should do the job.

gio
Contributor
Forum|alt.badge.img+15
  • Contributor
  • April 22, 2015
Chopper, max 2 verts.

 

 

Aquire angle of lines. Check if agles are in same relevant quadrant.

zzupljanin
Contributor
Forum|alt.badge.img+5
  • Author
  • Contributor
  • April 23, 2015
NielsGerrits, that was my idea: explode everything on vertices and calculate test if difference of neighbouring vertices A-(A+1)>0. The problem is that I don't know how to say that in AttributeCreator or Tester. The other problem is that based on start point of polyline the statement might be <0.

 

 

Gio, I didn't think of that but it works: Of course, first you need to do is CoordinateSwapper and then see if the Azimuth goes to different quadrant. Still, there lies a problem where is the start point of polyline. So the trick is to construct a conditional statement for findning different quadrant in one that most of polyline is.

david_r
Celebrity
  • April 23, 2015
Hi,

 

 

try the following code in a PythonCaller, it will output one point feature at each vertex of a polyline that has a higher z-value than the previous vertex:

 

 

---

 

import fme

 

import fmeobjects

 

 

class ZDirectionTester(object):

 

    def __init__(self):

 

        pass

 

        

 

    def input(self, feature):

 

        # For each feature, test that Z coordinate values are in

 

        # descending order. If not, output point features on the

 

        # offending vertex

 

        coords = feature.getAllCoordinates()

 

        z_values = [c[2] for c in coords]

 

        for n, z in enumerate(z_values):

 

            if n == 0:

 

                prev_z = z

 

            else:

 

                if z > prev_z:

 

                    point_feature = feature.cloneAttributes()

 

                    point_feature.addCoordinate(*coords[n])

 

                    point_feature.setGeometryType(fmeobjects.FME_GEOM_POINT)

 

                    self.pyoutput(point_feature)

 

                prev_z = z

 

                    

 

    def close(self):

 

        pass

 

---

 

 

David

takashi
Celebrity
  • April 24, 2015
Hi,

 

 

If you chop the polyline into individual line segments (use a Chopper with Maximum Vertices = 2), you can determine whether each segment is z-ascending or z-descending by comparing z-values of its start and end nodes.

 

You can use two CoordinateExtractors to extract z-values of start and end nodes.

 

 

But I think it would also be enought to compare z-values of start and end nodes of the original polyline, if your purpose is just to determine whether each polyline is z-ascending or z-descending. Because the vertices of a river line basically should be lined in the order of going gradually to either higher or lower.

 

 

Takashi