# How to find intersections of lines less than 45° in FME

I'm trying to identify intersections of electrical transmission lines that are less than 45° in FME. While, in theory, this doesn't seem like such a daunting task, in practice, it's proving quite difficult.

I can easily determine intersection points using the Intersector Transformer. However, the problem I'm having is twofold:

1. I'm unable to accurately identify all crossings that are 45° or less using this method. The Intersector Transformer provides a fme_node_angle attribute which contains the angle in degrees of the intersection. However, I don't know how helpful this is.
2. There are cases when there are multiple lines running coincidentally and then diverge. For example, in the below image, F1907 and F1908 follow the same path and then diverge: The Intersector transformer identifies this point as an intersection, but it is not valid for my purposes.

What I really need is a way to identify "true" intersecting lines. That is, the lines actually cross paths and the angle of intersection is less than 45°. A valid intersection might look like this:

Other things to note:

• There may be two lines running coincidentally which cross another line (or two lines). This is potentially a valid crossing.

• I have looked at the LineOnLine transformer, but this doesn't give me angles of intersection.

Hope this makes sense.

• If you won't get an FME-based solution, would an arcpy-based solution be helpful? Have written some code for that... Commented Apr 21, 2015 at 7:11
• Ideally I need an fme solution. However I am happy to see an arcpy solution too. I may be able to incorporate it into my fme model using a python caller.
– Fezter
Commented Apr 21, 2015 at 7:13
• Let's wait for FME folks first :) I'll get back to this post after some time. Commented Apr 21, 2015 at 8:43

PolylineAnalyzer (from the FME Store)

you can type 'PolylineAnalyzer' on the workbench worksheet and download from there.

Takes polylines and polygons and analyzes relationships between their components - vertices and segments.

usage: You can work the angle out and then use a tester transformer for 45 degrees or less

• I had thought of this. It won't work on its own as I need to find angles of intersections not angles of lines. I have used it in my final solution, however.
– Fezter
Commented Apr 22, 2015 at 3:50

Ok, I've figured this out. Steps are as follows:

1. Use a PolylineAnalyzer and output segments only (this method is better, but slower than just using a Chopper transformer as it outputs angles of segments).
2. Intersect the segments using an Intersector transformer and output nodes. Store incoming segments in a list.
3. Ensure the intersection nodes are not endpoints of the segments.
4. Use a listStatisticsCalculator Transformer to calculate the range of the `acAngle` attribute in the list. This attribute is created in the PolyLineAnalyzer. Calculating the range is essentially calculating the `max - min`.
5. Use an expressionEvaluator to create an attribute which stores the following `@tan(@degToRad(@Value(stats_range)))` value.
6. Use a tester to check for values between -1 and 1 which equate to angles less than 45°.

Results are only 11 intersections points out of close to 15,000 which come out of the Intersector.

If the LineOnLineOverlayer (According to the help files) does indeed give a list of the lines associated with the intersection. You could get the line start and end vertices for each line (CoordinateExtractor) perhaps after clipping to a small area around the intersection.

Then it's into the 'ExpressionEvaluator' for some back to basics trigonometry to get your angles. You could also check that both lines have coordinates either side of the intersection coordinate.

I would have done this as a comment only but, I don't have any rep points...

• Thanks for the answer. I have thought of using the LineOnLineOverlayer as I mentioned in my post. It sort of gets me there, but not completely. +1 for your first stackexchange post. Thanks.
– Fezter
Commented Apr 22, 2015 at 3:51