Question

Creating a line between 2 nodes

  • 19 November 2013
  • 5 replies
  • 18 views

Hi

 

 

I have a list of nodes with the x and y coordinates and I also have a list of the lines I would like to create in the form of from_node and to_node. I would like to create polylines between these specified nodes to basically create a network that I can then add other attributes to.

 

 

I am having trouble working out how to do this and would love some help!

5 replies

Badge +14
Hi - an example structure of your input data would help to be able to properly assist. But I suspect you'll need to use a 2DPointConnector to plot the start and end points and then use the PointConnector to join the start and end based on their LineID.
Hi Dave

 

 

So i have x and y coordinates (in British national Grid for each data point/ node) like so:

 

Node_ID X Y 0 450281.8 276693 3 450199.3 276613.3 4 450097.5 276453.7 6 450060.5 276390.4 7 450038.7 276360.2

 

 

(This list is actually huge and there is about 800 nodes)

 

and then i know which ones I want to connect and the order I want them drawn:

 

   From_node To_node 0 3 3 0 3 4 7 6 6 7
Userlevel 2
Badge +17
Hi,

 

 

Several approaches can be considered. One possible way is:

 

1) Use a FeatureMerger to append From (X, Y) to each From-To feature. From-To List --> REQUESTOR Node List --> SUPPLIER Join On: From_node, Node_ID 2) Transform From-To feature to a point (X, Y) with the 2DPointReplacer, then remove (X, Y) with the AttributeRemover. 3) Use 2nd FeatureMerger to append To (X, Y) to each point feature (ex-From-To feature). Point --> REQUESTOR Node List --> SUPPLIER Join On: To_node, Node_ID 4) Add a point (X, Y) to the point feature with the 2DPointAdder. Then, it will be a line segment.

 

Hope this helps.

 

Takashi
Userlevel 4
Badge +13
Hi,

 

An alternative way would be (assuming you have csv files):

 

Read the from2to file,

 

Use a joiner on the nodes file : feature attribute > from_node, table field> node_id, fields to add >XY, added fields prefix > from

 

A second joiner on the nodes file : feature attribute > to_node, table field> node_id, fields to add >XY, added fields prefix > to

 

2DPointReplacer: X value> from_x, Y value> from_y

 

2DPointAdder: X value> to_x, Y value> to_y.

 

 

Itay
Hi guys

 

 

Thanks for the help. Not sure what I am doing wrong but when i open the shapefile in GIS it is empty.

 

I have reader= routes (from-to)

 

joiner1:dataset=nodes, feature attribute= from_node, table field= node id, fields to add: X,Y,added field prefix = from

 

joiner2:dataset=nodes, feature attribute= to_node, table field= node id, fields to add: X,Y,added field prefix = to

 

then the joined output from joiner 1 goes to 2d point replacer (x value= from_x, y value= from y

 

joined output from joiner 2 goes to 2d point adder (x value= to_x, y value= to_y)

 

outpot and point from 2d point replacer and 2d point adder go to my new shapefile

 

 

any ideaS?

Reply