Question

Find the nearest line to the point

  • 22 February 2019
  • 8 replies
  • 94 views

Badge +1

Hello,

I have point dataset and line dataset. I would like to find the closest lines to each individual point. I am basically using the Neigborfinder. However, it does not fine correctly. I have labelled the id of the points and the closest one that have been idetfied by NeighborFinder. As you can see, it finds more than closest for some points.

I do not know what I am doing wrong. I would be happy if you can help me.

 


8 replies

Userlevel 1
Badge +21

I think if you want the closest line to each point, the points need to be your base and the lines the candidate

Userlevel 4

I agree with @egomm.

It may be easier to understand if you think of the "Matched" port as "MatchedBase", meaning that it's the BASE feature that will exit if it's found a CANDIDATE within the maximum distance.

 

Badge +1

I think if you want the closest line to each point, the points need to be your base and the lines the candidate

If i do so, the match output is the points as my input data

Userlevel 1
Badge +21

If i do so, the match output is the points as my input data

If you want to get the lines there are a couple of options you could consider

1) extract the line geometry as an attribute, merge the attributes with in the NeighborFinder and rebuild your line from the merged attribute

2) each point should have a line id of the line closest to it, use this line id as a supplier in a featuremerger with the requestor being the original lines

The best approach will depend on which attributes you wish to keep from each line/point

Badge +1

I agree with @egomm.

It may be easier to understand if you think of the "Matched" port as "MatchedBase", meaning that it's the BASE feature that will exit if it's found a CANDIDATE within the maximum distance.

 

I want closest lines to exits as matched. The lines that are the closest to points. If I set the point as base, the matched output is points themselves.

Badge +1

If you want to get the lines there are a couple of options you could consider

1) extract the line geometry as an attribute, merge the attributes with in the NeighborFinder and rebuild your line from the merged attribute

2) each point should have a line id of the line closest to it, use this line id as a supplier in a featuremerger with the requestor being the original lines

The best approach will depend on which attributes you wish to keep from each line/point

Thanks a lot for the options. I have used the geometry extractor before neigborfinder. And the output points have the lines geometry as you describe. However, I could not fine the way to rebuild the lines from the merged feature. Is there any transformer you could think of?

Userlevel 1
Badge +21

Thanks a lot for the options. I have used the geometry extractor before neigborfinder. And the output points have the lines geometry as you describe. However, I could not fine the way to rebuild the lines from the merged feature. Is there any transformer you could think of?

@jugoslaviaa you want to use a geometryreplacer to rebuild the lines from the geometry attribute

Badge +1

@jugoslaviaa you want to use a geometryreplacer to rebuild the lines from the geometry attribute

Works! Thank you very much!

Reply