Question

Detect parallel line

  • 20 June 2018
  • 3 replies
  • 16 views

Userlevel 1
Badge +11

Hi guys

I need to detect two parallel line within certain distance (15m) in a road network


3 replies

Userlevel 2
Badge +17

Hi @checcosisani,

You can do this using the following transformers:

- CoordinateExtractor to get the first and last coordinates of the segment

- ExpressionEvaluator to calculate the angle of the segments from the coordinate values, using atan2()

- NeighborFinder to find all line within 15m and store their attributes in a list

- ListSearcher to find nearby segment angle that matches the target line angle

- ListSearcher to find the reciprocal angle, in case the nearest line is drawn in the opposite direction.

Userlevel 1
Badge +11

Hi @checcosisani,

You can do this using the following transformers:

- CoordinateExtractor to get the first and last coordinates of the segment

- ExpressionEvaluator to calculate the angle of the segments from the coordinate values, using atan2()

- NeighborFinder to find all line within 15m and store their attributes in a list

- ListSearcher to find nearby segment angle that matches the target line angle

- ListSearcher to find the reciprocal angle, in case the nearest line is drawn in the opposite direction.

Hy Dave

 

 

I tried to built the wb but ......

 

 

Attached the data and the WB

 

 

can you help please ?

 

 

thx

 

 

Francesco

 

 

 

test-parallel-line.zip

 

Userlevel 2
Badge +17

Hi @checcosisani,

The roads in your data are sort of parallel, but not truly. I had to use a more complex process to find them.

The attached workspace contains the custom transformer FuzzyParallelLineFinder, which breaks the lines into small segments, then uses the NeighborFinder to find nearby line segments with a similar angle.

These matches are sent to a StatisticsCalculator to calculate the standard deviation of the distance between all the matching segments for all line pairs. The horizontal overlap for the matches is also calculated.

The lower the standard deviation on the segment distances, and the larger the overlap, the closer the lines are to being parallel to each other. The transformer picks the best match, but also includes a list of all the reasonable matches, along with the overlap and standard deviation, so you can choose your own best match, if you like.

The transformer has two parameters:

- Sampling Distance: the length of the test segments

- Search Distance: maximum distance for parallel lines

This process works best when the parallel lines start and end near the same point. The transformer provides the standard deviation of its best match as well, so you can use that to filter out poor matches.

The one downside of this process is that it is very slow. A large sampling distance will improve the speed, but at the cost of accuracy. If you are happy with the results, I will look into streamlining it by using Python for the list handling. If any other members here can suggest improvements, they are most welcome.

detect-parallel-line.fmw

Reply