Answers for "How do I find the closest point object to a line objects start and end node (vertex)" https://knowledge.亚搏在线safe.com/questions/22173/how-do-i-find-the-closest-point-object-to-a-line-o.html The latest answers for the question "How do I find the closest point object to a line objects start and end node (vertex)" Answer by gio https://knowledge.safe.com/answers/57226/view.html

@trentanderin

Hi comleted your workspace.But have some remarks and questions, mainly related to the bojects on the nodes.Do you want those related to the lines?

In the workspace i relate only the objects between the nodes.You can easily have the ones on teh nodes relaed in the first bit (where is exclude them from the process).

test-copper.fmwt

Fri, 03 Nov 2017 21:35:03 GMT gio
Answer by gio https://knowledge.safe.com/answers/57150/view.html

@takashi

Of course Neighbourfinder approach yields result.

I always try to avoid to have to guess what the search range would have to be.IF you just set a huge range or for instance the Diameter of the data bounding box, the neighborfinder has a lot of work to do (and consequently consumes time and memory).

I prefer to do away with that.( in fact I have build a iterative neighbourfinder years ago to prevent useless searches)

I just avoid its use when not necessary.

Also I thought you would appreciate the fact that there are "many ways to kill a cat".

Certainly in the question bytrentanderinits is totally not necessary.As the points, as he stated are actually on the line.You could even solve that one by setting measures.

Also I wish safe would one day fix the spatialrelator.

Fri, 03 Nov 2017 10:29:39 GMT gio
Answer by takashi https://knowledge.safe.com/answers/57134/view.html

You can use two Snippers to create start and end nodes of the line, and find points closest to those nodes separately with two NeighborFinders.This is a mock-up.

If you need to preserve the original line geometry, you can use a GeometryExtractor before the Snipper to store the geometry as an attribute and use a GeometyReplacer after the FeatureMerger to restore the geometry from the attribute.

Fri, 03 Nov 2017 07:51:58 GMT takashi
Answer by gio https://knowledge.safe.com/answers/57067/view.html

@trentanderin

Here is a workspace to do it.No searching for anything.Just topo and nodenumbers.

Thu, 02 Nov 2017 13:34:18 GMT gio
Answer by gio https://knowledge.safe.com/answers/57046/view.html

@trentanderin

When points are always on lines you can simply use a

Topology builder on the (poly)lines which gives you the begin and end point the (poly)lines( node output).

Then (for instance) a pointonpoint overlayer with the points.(PoP has a tolerance setting in case there is any accuracy problem)


Wed, 01 Nov 2017 23:53:30 GMT gio
Answer by gio https://knowledge.safe.com/answers/57012/view.html

As you don't know the distance to set for the neighbor finder (you might end up having to search half the map), I would suggest a different approach.

1) If you have a large amount of objects:

I would start to tile the data set by a percentage of the boundingboxes ( scale 2x or maybe larger) of the lines.

Then Relate all objects in each b-box, lines and points.(spatialrelator)

2) Merge lines and points grouped by b-boxes.

Extract end and startpoint of line (index 0 and -1 with coordinate extractor).Extract coord of points.Name attributes appropriately.

simple lengthcalculation for start and end to point.

( you know..for end E to point P for instance

@sqrt(@pow( E_x - P_x,2) @pow(E_y-P_y,2))

)

If you do this conditional using attribute creator you can simultaneously test which is shortest and set it to a "distance" attribute.

Then Sort by LineID and "distance" attribute, ascending.

Sample by LineID, 1, first n features.

Wed, 01 Nov 2017 16:46:23 GMT gio
Answer by trentanderin https://knowledge.safe.com/answers/56933/view.html

@erik_jan.Hi there, i have the same problem as the question but can't seem to get your anwser to work, i have many line objects and many point objects that sit on these lines.I want to be able to output a csv file that contains all details of the line with two extra columns that 1.contains the closest point object to the start vertex of the line and 2.contains the closest point object to the end vertex of the line.I have had a play with your answer above but had no luck, is there any way of providing an example workbench to view on how it is structured?

Wed, 01 Nov 2017 14:23:37 GMT trentanderin
Answer by erik_jan https://knowledge.safe.com/answers/22174/view.html

Use the CoordinateExtractor (index 0 for start and index -1 for end) to extract the start and end coordinates.

Use the 2DPointReplacer to replace the line using start coordinates.

Use the NeighborFinder to find closest point to start.

Repeat last two steps for end coordinates.

Wed, 13 Jan 2016 01:28:12 GMT erik_jan