Question

Is it possible to calculate the average distance between two lines ?

  • 10 February 2022
  • 4 replies
  • 114 views

Badge +8

I have a dataset of two lines and I want to calculate the average distance between them. I can use the NeighborFinder to get the closest distance between these two lines. (As you can see on the image the closest distance could only be an outlier.)

But I want to know how far they are from each other in average as these two lines are almost parallel. Is this possible to calculate ?


4 replies

Userlevel 4
Badge +30

Hi @katt​ 

 

Have you tried to extract the points ( begin and end ) of the lines first?

 

 

 

Thanks in Advance,

 

Danilo

Badge +8

Hi @katt​ 

 

Have you tried to extract the points ( begin and end ) of the lines first?

 

 

 

Thanks in Advance,

 

Danilo

Hey danilo_fme, I am not sure why to do so? Also the following scenario is possible. The outlier is not necessarily at the end/beginning of the line.image

Userlevel 5
Badge +29

Heres one approach, Assume you name one line 'A' and one line 'B'

imageOn line A use the iterative snipper and split into X number of lines. then extract the first coordinate and use those as the origins in the Rotator. Rotate the line 90 degrees. These lines (we'll them 'C') are now perpendicular to line A.

imageNow extend C a suitable distance to be sure they intersect both lines A and B.

image 

Then using an intersector 'cut' C into three parts, then use a spatial filter to find the C segments that fall between A and B

imagenow calculate the length of the cut C segments and use a StatisticsCalculator to get the average length of all the C lines.

 

Have a look at the attached workbench :)

Userlevel 2
Badge +17

Hi @katt​ , here is another approach. ​The basic concept is:

average distance = area between the two lines / longer axis length of the area

The attached workspace is an implementation example.

Reply