Solved

Calculating Nearest Distance Left/Right Between Parallel Linear Features


I have 4 linear features that are all parallel from eachother, and set at unequal spacing from eachother. I am looking to calculate the nearest distance left and right from each linear feature to the next linear feature. Having trouble figuring out how to make this work. Any help is much appreciated

icon

Best answer by jdh 1 September 2016, 16:29

View original

10 replies

Badge +22

I would use a LeftRightSpatialCalculator with your features sent to both base and candidate to get a relative position list of which features are to the left vs right (the current feature will be undefined) - you need a Key attribute for this.

 

Then a neighborfinder (candidates only) with the Close Candidate list (for your specific case you can set the number of neighbours to 3, in a more generic case the number of neighbours should be the maximum number of candidates on a side +1, I would use a list histogrammer on the relative position list to determine that.)

 

 

You can then go through the close candidate list to get the Key ID of the closest feature and then check the relative position list to see if it's left or right. Keep going through the close list until you find both a left and right, or reach the end of the list (one feature will have no left, and the other no right)
Badge +10

I think you'll need to bury yourself in Lists for this one. I think the LeftRightSpatialCalculator and the NeighborFinder should get you close to what you're looking for. Something like the attached, though with more effort to extract the intel from the lists.

Cheers, Dave

neigh.fmw

Badge +10

I would use a LeftRightSpatialCalculator with your features sent to both base and candidate to get a relative position list of which features are to the left vs right (the current feature will be undefined) - you need a Key attribute for this.

 

Then a neighborfinder (candidates only) with the Close Candidate list (for your specific case you can set the number of neighbours to 3, in a more generic case the number of neighbours should be the maximum number of candidates on a side +1, I would use a list histogrammer on the relative position list to determine that.)

 

 

You can then go through the close candidate list to get the Key ID of the closest feature and then check the relative position list to see if it's left or right. Keep going through the close list until you find both a left and right, or reach the end of the list (one feature will have no left, and the other no right)
Ahhh, when posts collide! I must learn to refresh the page before posting. Oh well, at least we both had the same thoughts...

 

 

Badge +22
Ahhh, when posts collide! I must learn to refresh the page before posting. Oh well, at least we both had the same thoughts...

 

 

Happens to me all the time.

 

 

Thanks guys, this is very helpful. I was close. Let me try this out, and see what this gets me. The challenge with this particular workflow is that I am needing to run this on a dataset of about 1000+ linear features.

Badge +22

Thanks guys, this is very helpful. I was close. Let me try this out, and see what this gets me. The challenge with this particular workflow is that I am needing to run this on a dataset of about 1000+ linear features.

In which case you will want to detemine the number of neigbours to find at run time.

 

 

When dealing with large numbers of features and lists, prune as much as possible as fast as possible.

 

 

get rid of all the candidate angles, label angle, closest xy, fme attributes and especially the _nearest{}._relative_position{}

 

 

what you want is just

 

(key attribute)

 

_relative_position{}.base_id

 

_relative_position{}.position

 

_nearest{}.(key attribute name)

 

_nearest{}.distance

 

 

When looping though or comparing lists, I generally find that python is more efficient

 

Userlevel 4
Badge +25

I'd say the NeighborPairFinder is the best solution... provided that your lines are really parallel and at regular spacing/intervals. If the lines intersect or have unequal spacing (eg you have two lines on the left that are both closer than the nearest line on the right) then it's going to be a tougher task - but as the other good folks here have said, the LeftRightSpatialCalculator will help, as would the _angle attributes from the NeighborFinders.

Badge +3

@dcal122890

..post failed?

lines are paralell...so..

Aggregate the lines.

Create oriented bounding box.

Coerce to box to line.

Create mid line (or if needed half-, quarterlines. Depending on distribution of lines)

Intersect box with the paralel lines. (use list)

At least one line will now be intersected by all lines (test for number of nodes = number of paralell lines) and yielding your answer (in a list)

 

Badge +22

I'd say the NeighborPairFinder is the best solution... provided that your lines are really parallel and at regular spacing/intervals. If the lines intersect or have unequal spacing (eg you have two lines on the left that are both closer than the nearest line on the right) then it's going to be a tougher task - but as the other good folks here have said, the LeftRightSpatialCalculator will help, as would the _angle attributes from the NeighborFinders.

Even at unequal spacing, if the lines are perfectly parallel. then if you set the minimum separation angle to 180, it will pick up the closest line in either side. However it does not indicate which line if the left line and which line is the right , and the two edge lines will be "Unmatched base".

 

 

Badge +3

@dcal122890

something like this..

Reply