Skip to main content
Hi,

 

 

I've been playing around with the Looper transformer to try and extract out peaks from a height dataset.  It's quite hard to explain(!) so I've saved a PDF of screenshots here:

 

 

http://db.tt/MehXB4zJ

 

 

I have a point DTM  dataset that I have derived from a previous workbench.  In the previous workbench I had a pair of rail strings (one for each direction) for which I generated perpendicular lines and extracted out the points where the perpendicular lines intersected a contour dataset, image p1.

 

 

Each "line" of points is derived from two sets of perpendicular lines, one for each direction so if you imagine a set of tracks down the middle, I'm only looking at the points one perpendicular line at a time (in the screenshot, it's the set to the south-west of the rail line)

 

 

As an example, on image p2 & p3 I have selected one of four points I want to interrogate via the Looper.  Each set of points along the rail string has a common count value (so they can grouped), all the points along this perpendicular line have the unique count 2483.  They also have a mitigation distance which is the distance from the original rail string.

 

 

I want the Looper to go through each unique set of points (i.e. grouped by the unique count value) and pick out peaks, using the mitigation distance to order the points (ascending).  There could be an number of points to interogate, not just four as in the screenshots, eg. if the height values are:

 

 

10

 

20

 

>30

 

20

 

10

 

>40

 

10

 

>50

 

30

 

 

I want the ones highlighted extracted, i.e. where the next value is lower than current value, write out that value.  Again, mitigation attribute to feed the points into the transformer in the right order. 

 

 

Image p4 shows by main workbench where I have used the Sorter to puts all mitigation heights in order and also created a _value attribute to feed into the Looper.

 

 

Image 5-7 show the Looper and its parameters.  I'm using a Tester to try and extract out the max values.  When I run the workbench it runs, gets past the Sorter but then just keeps runnning, without completing (log doesn't move).  If I don't create the _value attribute in the main workspace it also hangs it the same place.  Have I created an infinte loop??  The point dataset has 124,000 points approx, so not huge.

 

 

Sorry for the long explanation, but any help gratefully received!

 

 

Thanks, Amit
Hi Amit,

 

 

do you think it would be possible to replace your looping transformer with a StatisticsCalculator with a Group by? I'm guessing it would be quicker.

 

 

David
Hi David, thanks for the reply.  I've had a look at the StatisticsCalculator and can see how to extract out certain key vales, however it's less clear how I can extract out peack values (rather than the max or highest range).  Any tips?
Hi Amit,

 

 

for your looping transformer, have you tried setting an inspection point and following the flow of features inside? That would normally be a good way to isolate infinite loops or faulty operators.

 

 

Since I really Python incredibly powerful when used with FME, here is a solution (untested!) that could be implemented using only a PythonCaller:

 

 

def featureProcessor(feature):     heights = feature.getAttribute("myValues{}")     peaks =  ]     n = 0     while n < (len(heights)-1).         height = heights n]         next_height = heights n+1]         if height > next_height:             peaks.append(height)                  for n, peak in enumerate(peaks):         feature.setAttribute("myPeaks{"+str(n)+"}", peak)

 

It assumes that each of your features have a list "myValues{}" that contains your DTM heights along the line feature. It will add a list to each feature called "myPeaks{}" with all the values where HEIGHT(n) > HEIGHT(n+1). You will have to expose "myPeaks{}" in the PythonCaller to see it in the workspace.

 

 

Hope this can give you some ideas. Give me a word if something is unclear.

 

 

Good luck.

 

 

David
Hi David,

 

 

Thanks for the script!  One of my colleagues is a lot more experienced at Python so we're going to have a look at it together, I'll report back.   Thanks again.

 

 

Amit

Reply