Skip to main content
Solved

Filtering procedure for vertices based on elevation difference, Loop

  • February 5, 2025
  • 3 replies
  • 59 views

matthieu_polyte
Contributor
Forum|alt.badge.img+4

I wish to implement a filtering procedure for the vertices of each polyline. The goal is to retain only the vertices where the elevation difference between consecutive points exceeds a specified threshold, for example, 10 cm.

I have developed a script that extracts all the vertices and identifies them based on the polyline to which they belong, as well as their specific index. The process involves testing the elevation difference between each pair of consecutive points. If this difference is below the threshold, the point should be eliminated, and the process moves on to the next point.

Example of the process:

  • If Z_PL1_1​​ − Z_PL1_2​​<0.1, then point PL1_2 should be eliminated. Next test: 
  • If  Z_PL1_1​​ − Z_PL1_3​​>0.1, then the point PL1_3 is retained. Next we test PL1_3 with the other points of the polyline excluding PL1_2, and so on. 

This principle is applied iteratively to all polylines.

Problem encountered:

I am facing difficulty with the implementation of iterations to apply this logic to all points automatically. I am unsure how to structure the iterations so that the script can efficiently and consistently filter each pair of consecutive points.

Actually, I am not very skilled with iterations. If there is another way to achieve this without using loops, that would be great.

Best answer by bwn

Possibly overthinking this.  You shouldn’t need iteration.

Can step through each Vertex as Point Features with AttributeCreator in Adjacent Features mode with Conditional Values, and flag which vertices to “keep” in one pass by tracking and updating a Reference Z value as step through each Point Feature.

The basic logic is:

  • By default, set the “keep_point” flag to TRUE (ie. 1)
  • Initialise reference_z as the z value of the first point.  reference_z being the value we wish to compare the current Feature’s Z against.
  • If for the previous Point, keep_point = 1, then update the reference_z = The previous feature’s Z coordinate, otherwise, don’t change the reference_z and keep the value the same
  • If the Z of the current Feature is within 0.1 of reference_z, then Set keep_point = 0 (and this will in turn on the next Feature make it so that the reference_z will not get updated with the discarded point Z value)

 

AttributeCreator Adjacent Features + Conditional Values



 

 

 

View original
Did this help you find an answer to your question?
This post is closed to further activity.
It may be a question with a best answer, an implemented idea, or just a post needing no comment.
If you have a follow-up or related question, 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.

3 replies

bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • Best Answer
  • February 7, 2025

Possibly overthinking this.  You shouldn’t need iteration.

Can step through each Vertex as Point Features with AttributeCreator in Adjacent Features mode with Conditional Values, and flag which vertices to “keep” in one pass by tracking and updating a Reference Z value as step through each Point Feature.

The basic logic is:

  • By default, set the “keep_point” flag to TRUE (ie. 1)
  • Initialise reference_z as the z value of the first point.  reference_z being the value we wish to compare the current Feature’s Z against.
  • If for the previous Point, keep_point = 1, then update the reference_z = The previous feature’s Z coordinate, otherwise, don’t change the reference_z and keep the value the same
  • If the Z of the current Feature is within 0.1 of reference_z, then Set keep_point = 0 (and this will in turn on the next Feature make it so that the reference_z will not get updated with the discarded point Z value)

 

AttributeCreator Adjacent Features + Conditional Values



 

 

 


matthieu_polyte
Contributor
Forum|alt.badge.img+4

Wow, this is a completely different way of looking at the problem. I find this approach of flagging points and advancing the reference Z when keep_point is 0 very interesting. It works perfectly for a single polyline. However, in my case, I have many polylines to process this way. I haven’t found a way to group the processing by polyline yet, as the AttributeCreator transformer does not allow grouping.


bwn
Evangelist
Forum|alt.badge.img+26
  • Evangelist
  • February 10, 2025

For AttributeCreator, can mimic Group By in again using Conditional Values to detect where a value has changed that denotes a change in Group (and if needed an initial Sorter to place the Features in each Group adjacent to each other and in an Order that a Group Change can be detected……...but in this case you will almost certainly already have the Vertex Points in a sort order already)

For example, can use either a Point/Vertex ID value (Option 1) or a Line ID value (Option 2) to detect that another line “group” has commenced.

 



The extra Condition can then be added to the second AttributeCreator to detect this as the priority first “If” condition and instead initialise “reference_z” to a dummy value of -99999 to denote it is the first on the line and that this will make the next condition statement checking if Absolute(Point Z - Reference Z) < 0.1 always evaluate to False on the first point and hence the First Point will always be “kept”.
 

reference_z

 

...The extra condition above is using LineID to detect a Group change in Line.   If using the Vertex ID method, then would be instead If @Value(VertexID)<@Value(feature[-1].VertexID)

 


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