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.
@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?
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.
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.
The point objects will always be found on every vertex of a line object. I have lots and lots of line segments (some have only 2 vertexes where other segments have many) and the points will sit on each vertex, but i only want to pull out the points that touch the start and end vertex. How should i structure my workbench to accomplish this?
@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)
@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)
a pic to illustrate it
@trentanderin
Here is a workspace to do it. No searching for anything. Just topo and nodenumbers.
@trentanderin
Here is a workspace to do it. No searching for anything. Just topo and nodenumbers.
Hey there,
because i'm still a noob when it comes to stuff i haven't done before i have uploaded my workbench with sample data i am working with. Are you able to have a look as i'm not to sure of the setting in each of the transformers :|.
I appreciate any more help you can offer
test-copper.zip
Cheers
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.
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.
The approach is basically equal to @erik_jan's answer. I don't know why his method couldn't help you.
In addition, CoordinateRemovers can also be used instead of the Snippers.
@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 by trentanderin its 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.
Hey there,
because i'm still a noob when it comes to stuff i haven't done before i have uploaded my workbench with sample data i am working with. Are you able to have a look as i'm not to sure of the setting in each of the transformers :|.
I appreciate any more help you can offer
test-copper.zip
Cheers
@trentanderin
Hi I have been getting it working with some adaptation to the original workbench I posted, but I have a question about the data.
In the Rotorua_Poles_test dataset you have points that are on the end- or start (half of the points about) of a lot of 11kv__064_COPPER_TEST line.
Do these need to be tested also? (because then points in between the end and begin will always fail)
I have set it up to first remove these and then test the rest. But I have no idea if this is intended.
Greets
Gio
@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