Hi,
the NeighborFinder adds the following attributes that might be of interest to you: _closest_candidate_x and _closest_candidate_y. You can use those in a VertexCreator to create a line from the BASE point feature.
See also:
http://docs.safe.com/fme/html/FME_Transformers/Default.htm#Transformers/neighborfinder.htm
David
Hi guys
I have attached a picture above. Basically the PGPS_nodes is file 1 that I want to find the cloest node in file 2 for each.
I have used coordinate extractor then neighbour finder and then a vertex creator based on the _closest_candidate_x and _closest_candidate_y but I dont know how to create the line from here.
Hi,
based on your screenshot it seems like you haven't got any matches. Just make sure that you've entered a large enough "Maximum distance" in the Neighborfinder (NB: it's in ground units of your coordinate system). For the VertexCreator, make sure that it's set to "Add vertex".
David
Hi David
I have zipped my files and attached them. i only have the option to "add point" in the vertex creator. Apologies if I am missing something obvious.
Zoe
https://arup.sharefile.com/d/sc89d19385f645e58
Hi Zoe,
there doesn't seem to be anything wrong with your workspace. However, your dataset PGPS_final_v2 contains polylines, not points. That might explain your unexpected result.
David
Hi David
I am trying to create a polyline between that connects to the closest point it found.
Hi,
not quite sure I understand what you're trying to accomplish. Are you perhaps trying to fix faulty topology connections? If so, consider using the AnchoredSnapper.
David
Hi
So I have a set of points "nodes" and I want to draw a line between each of those points and the closest corresponding point in the "final_v2" file (based on distance).
Use a unconditional featuremerger to merge all PGPS nodes to all PGPS_final nodes.
Make sure coordinates from extractor have not the same name: Like From_x, From_Y and the other To_X,To_Y.
At merged output use a vertexcreator (create) on From and then a vertexcreator (add) on To.
Create ID on lines using a counter.
Claculate lentgh.
Create a list grouped by ID.
Listsort on length, ascending.
Listindex{0} to choose 1st in list wich is shortest.
..with the ID you can pick the shortest geometric lines using a featuremerger
btw, you can ofcourse refrain from using vertexcreators and do basic math for distance calculaten
distance = SQRT((POW(To_x - From_x)+POW(To_Y -From_Y))
and list by ID sort and pick first.
And create the line after the points are picked. More efficient if u have huge numbers of points.
Hi Zoe,
I had a look at your data and workspace.
PGPS_nodes.shp contains point features; PGPS_final_v2.shp contains line features.
The dataset looks like a road network.
In your workspace, the NeighborFinder will find points on the lines each of which is closest to a node, and the VertexCreator will connect every closest point and node pair to create lines.
However, since every node seems to be located at an end of a line, coordinate of the closest point is same as the node naturally. Therefore, the resulting geometries will be "no-length" lines consisting of duplicate 2 nodes.
Although the workspace works properly as designed, probably the result is not what you want. I think you will have to re-consider the workspace design.
First of all, your requirement has to be clarified, but I (and also maybe David and Gio) was not able to understand the requirement as long as seeing your posts.
To help us, could you please paste an image illustrating the relation between the source (nodes and lines) and the lines which you finally need?
Takashi
Hi,
At first i didnt see you posted the files. So, now i checked them out (pretty large file, it took 2mins15sec to read)
Like Takshi said, it is a network.
There are no sets of nodes to compare. There are only the topology nodes.
You're workspace has the nodes "find itself"
So it is indeed unclear what it is you wish to acomplish.
If you want to find nodes wich are closest to other nodes, you could use my suggested procedure, but use the pgps_nodes file to unconditionaly merge it to itself. That way you can find the closest node within the PGPS_nodes file itself. (this distance is "as the crow flies")
On the other hand u could use ShortestPathFinder to find closest nodes based on the network itself. (the network has direction, so it is possilbe to use the ShortestPathFinder transformer) This is not necessarily the same as "as the crow flies" distance.