How to assign node IDs to links in a network?Assigning point IDs to respective start and end attributes of...

When should a commit not be version tagged?

Replacement ford fiesta radiator has extra hose

Significance and timing of "mux scans"

Does music exist in Panem? And if so, what kinds of music?

Six real numbers so that product of any five is the sixth one

How to deny access to SQL Server to certain login over SSMS, but allow over .Net SqlClient Data Provider

Use comma instead of & in table

Called into a meeting and told we are being made redundant (laid off) and "not to share outside". Can I tell my partner?

Why does the author believe that the central mass that gas cloud HCN-0.009-0.044 orbits is smaller than our solar system?

What is better: yes / no radio, or simple checkbox?

How can I handle a player who pre-plans arguments about my rulings on RAW?

Can I become debt free or should I file for bankruptcy? How do I manage my debt and finances?

Equivalent to "source" in OpenBSD?

If nine coins are tossed, what is the probability that the number of heads is even?

How can atoms be electrically neutral when there is a difference in the positions of the charges?

What to do when being responsible for data protection in your lab, yet advice is ignored?

Should I choose Itemized or Standard deduction?

Must a tritone substitution use a dominant seventh chord?

Which aircraft had such a luxurious-looking navigator's station?

Is there a low-level alternative to Animate Objects?

Second-rate spelling

What's the purpose of these copper coils with resistors inside them in A Yamaha RX-V396RDS amplifier?

How to properly claim credit for peer review?

Has the Isbell–Freyd criterion ever been used to check that a category is concretisable?



How to assign node IDs to links in a network?


Assigning point IDs to respective start and end attributes of polyline?Determine start/end points for line slope calculationAssigning from node to node in ArcGIS geometric network?How can we extract the stream order branch?How to correct topology on a shared boundary by removing nodes from a feature?How to link a shapefile with points to a shapefile with lines?How to build a GRASS network with node IDs from the line dataset?How to reconstruct a network with multipart edges to a network with singlepart edgesHow to modify the “Network Analysis Library” in QGIS?Create a center node based on both polygon and line shapefileHow to get lines and nodes around the confluence point in a network system (line shapefile)?Making graph from network vector in QGIS?Nodes does not appear where they should be while creating network in ArcGISMaintain network hierarchy using attribute assistant













4















I have two shapefile layers in ArcGIS for Desktop 10.



I have one line layer and node layer.



My node layer(shp) has a "code_1" field and line layer has a "code_node" field.



The intersection point of the line layer has only one node.



I want get the code from the "code_1" field of the node layer for the line's "code_node" field



For example, for one line, the first node has code_1=1 and the node at the end of line has code_1=2. In this case the code_node attribute in that line must be "12",.



How can I automatically get the code from the nodes for each line?



enter image description here










share|improve this question

























  • What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

    – PolyGeo
    Feb 2 '14 at 9:22













  • Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

    – Devdatta Tengshe
    Feb 3 '14 at 2:52











  • I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

    – Devdatta Tengshe
    Feb 3 '14 at 2:56











  • reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

    – elena
    Feb 3 '14 at 4:17













  • reply PolyGeo: yes, I have network

    – elena
    Feb 3 '14 at 4:18
















4















I have two shapefile layers in ArcGIS for Desktop 10.



I have one line layer and node layer.



My node layer(shp) has a "code_1" field and line layer has a "code_node" field.



The intersection point of the line layer has only one node.



I want get the code from the "code_1" field of the node layer for the line's "code_node" field



For example, for one line, the first node has code_1=1 and the node at the end of line has code_1=2. In this case the code_node attribute in that line must be "12",.



How can I automatically get the code from the nodes for each line?



enter image description here










share|improve this question

























  • What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

    – PolyGeo
    Feb 2 '14 at 9:22













  • Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

    – Devdatta Tengshe
    Feb 3 '14 at 2:52











  • I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

    – Devdatta Tengshe
    Feb 3 '14 at 2:56











  • reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

    – elena
    Feb 3 '14 at 4:17













  • reply PolyGeo: yes, I have network

    – elena
    Feb 3 '14 at 4:18














4












4








4


2






I have two shapefile layers in ArcGIS for Desktop 10.



I have one line layer and node layer.



My node layer(shp) has a "code_1" field and line layer has a "code_node" field.



The intersection point of the line layer has only one node.



I want get the code from the "code_1" field of the node layer for the line's "code_node" field



For example, for one line, the first node has code_1=1 and the node at the end of line has code_1=2. In this case the code_node attribute in that line must be "12",.



How can I automatically get the code from the nodes for each line?



enter image description here










share|improve this question
















I have two shapefile layers in ArcGIS for Desktop 10.



I have one line layer and node layer.



My node layer(shp) has a "code_1" field and line layer has a "code_node" field.



The intersection point of the line layer has only one node.



I want get the code from the "code_1" field of the node layer for the line's "code_node" field



For example, for one line, the first node has code_1=1 and the node at the end of line has code_1=2. In this case the code_node attribute in that line must be "12",.



How can I automatically get the code from the nodes for each line?



enter image description here







arcgis-10.0 arcgis-desktop line network






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 11 '14 at 4:01







user681

















asked Feb 2 '14 at 8:11









elenaelena

2112




2112













  • What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

    – PolyGeo
    Feb 2 '14 at 9:22













  • Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

    – Devdatta Tengshe
    Feb 3 '14 at 2:52











  • I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

    – Devdatta Tengshe
    Feb 3 '14 at 2:56











  • reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

    – elena
    Feb 3 '14 at 4:17













  • reply PolyGeo: yes, I have network

    – elena
    Feb 3 '14 at 4:18



















  • What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

    – PolyGeo
    Feb 2 '14 at 9:22













  • Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

    – Devdatta Tengshe
    Feb 3 '14 at 2:52











  • I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

    – Devdatta Tengshe
    Feb 3 '14 at 2:56











  • reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

    – elena
    Feb 3 '14 at 4:17













  • reply PolyGeo: yes, I have network

    – elena
    Feb 3 '14 at 4:18

















What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

– PolyGeo
Feb 2 '14 at 9:22







What do you mean by a "node layer"? Are you perhaps using a geometric network or a network dataset or are these simply points located at intersections of lines in another layer?

– PolyGeo
Feb 2 '14 at 9:22















Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

– Devdatta Tengshe
Feb 3 '14 at 2:52





Hi, I've edited and updated the question to clarify what I think you were asking. If my understanding was incorrect, feel free to revert the question back to its original state.

– Devdatta Tengshe
Feb 3 '14 at 2:52













I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

– Devdatta Tengshe
Feb 3 '14 at 2:56





I think that this question could do with a few more clarifications. Firstly, what kind of solution are you looking for? Arcpy or ArcObjects? what have you tried so far? And Secondly, I think the code_node in the line would be ambiguous. Consider the code 1234; You can't say if the two codes are 1 & 234 or 12 & 34 or 123 & 4. It might be better if you keep a symbol for delimiting the two codes, say 12-34

– Devdatta Tengshe
Feb 3 '14 at 2:56













reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

– elena
Feb 3 '14 at 4:17







reply Devdatta Tengshe: I want find one way to do that, It does not matter which way, ArcObject or .... I need just join of 2 code like 1234

– elena
Feb 3 '14 at 4:17















reply PolyGeo: yes, I have network

– elena
Feb 3 '14 at 4:18





reply PolyGeo: yes, I have network

– elena
Feb 3 '14 at 4:18










2 Answers
2






active

oldest

votes


















4














Use Feature Vertices To Points to get the START points from the line shapefile. Do the same for END points. Name the resulted layers "start" and "end". Then use Spatial Join to join these resulted layers to your node layer separately (Target features: "start" and "end" layers, Join feature: your node layer, JOIN_ONE_TO_ONE, Match Option: Intersect). Name the resulting layers "startJoin" and "endJoin". Add a new field "origin" to your line layer (with the same properties as your "code_1" field, I suggest TEXT format). Join your line layer to "startJoin" (match FID to ORIG_FID) and by field calculator copy "code_1" in the "origin" field. Add another field "destination" to your line layer and do the same (you may want to remove the existing join before doing this) for "endJoin" and get the "code_1" into "destination" field. Fianlly, do this field calculation to your "code_node" field: [origin]&[destination]






share|improve this answer
























  • Is there anyway to do this using a spatial join instead of creating new temporary files?

    – Sarah
    Feb 28 '14 at 14:42











  • I am not %100 sure on that but I think we need the starting/ending points anyway.

    – Arash
    Feb 28 '14 at 17:00



















0














I like the approach suggested by @Arash, but this creates 3 additional files, which really adds up if you have a large network and need to check this regularly. Here's my solution using python.



The geometric network build forces the X,Y of the nodes and the pipe ends to be coincident. You can access these locations with the shape tokens in arcpy cursors and match them. The shape tokens for lines return an array of the vertices in the order that they were drawn. In my network, the draw order of the pipes is heavily QA'd because we use this to set the flow directions. So, the first vertex is the start of the pipe, and the last vertex is the end of the pipe.



Reference: ASSETID = id of pipe, UNITID = node id at start of pipe, UNITID2 = node id at end of pipe.



nodes = "mergeNodes"
pipes = "SEWER_1"

nodeDict = {}
pipeDict = {}

#populate node dictionary with X,Y as the key and node ID as the value
for node in arcpy.da.SearchCursor(nodes, ["UNITID", "SHAPE@XY"]):
nodeDict[(node[1][0], node[1][1])] = node[0]

#populate pipe dictionary with pipe ID as the key and list of X,Y as values
#vertices populated in the order that the line was draw
#so that [0] is the first vertex and [-1] is the final vertex
for pipe in arcpy.da.SearchCursor(pipes, ["ASSETID", "SHAPE@"]):
for arrayOb in pipe[1]:
for point in arrayOb:
if pipe[0] in pipeDict:
pipeDict[pipe[0]].append((point.X, point.Y))
else:
pipeDict[pipe[0]] = [(point.X, point.Y)]

#populate UNITID with the first vertex of the line
#populate UNITID2 with the final vertex of the line
with arcpy.da.UpdateCursor(pipes, ["ASSETID", "UNITID", "UNITID2"]) as cur:
for pipe in cur:
if pipeDict[pipe[0]][0] in nodeDict:
pipe[1] = nodeDict[pipeDict[pipe[0]][0]]
if pipeDict[pipe[0]][-1] in nodeDict:
pipe[2] = nodeDict[pipeDict[pipe[0]][-1]]
cur.updateRow(pipe)





share|improve this answer























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "79"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f85082%2fhow-to-assign-node-ids-to-links-in-a-network%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    4














    Use Feature Vertices To Points to get the START points from the line shapefile. Do the same for END points. Name the resulted layers "start" and "end". Then use Spatial Join to join these resulted layers to your node layer separately (Target features: "start" and "end" layers, Join feature: your node layer, JOIN_ONE_TO_ONE, Match Option: Intersect). Name the resulting layers "startJoin" and "endJoin". Add a new field "origin" to your line layer (with the same properties as your "code_1" field, I suggest TEXT format). Join your line layer to "startJoin" (match FID to ORIG_FID) and by field calculator copy "code_1" in the "origin" field. Add another field "destination" to your line layer and do the same (you may want to remove the existing join before doing this) for "endJoin" and get the "code_1" into "destination" field. Fianlly, do this field calculation to your "code_node" field: [origin]&[destination]






    share|improve this answer
























    • Is there anyway to do this using a spatial join instead of creating new temporary files?

      – Sarah
      Feb 28 '14 at 14:42











    • I am not %100 sure on that but I think we need the starting/ending points anyway.

      – Arash
      Feb 28 '14 at 17:00
















    4














    Use Feature Vertices To Points to get the START points from the line shapefile. Do the same for END points. Name the resulted layers "start" and "end". Then use Spatial Join to join these resulted layers to your node layer separately (Target features: "start" and "end" layers, Join feature: your node layer, JOIN_ONE_TO_ONE, Match Option: Intersect). Name the resulting layers "startJoin" and "endJoin". Add a new field "origin" to your line layer (with the same properties as your "code_1" field, I suggest TEXT format). Join your line layer to "startJoin" (match FID to ORIG_FID) and by field calculator copy "code_1" in the "origin" field. Add another field "destination" to your line layer and do the same (you may want to remove the existing join before doing this) for "endJoin" and get the "code_1" into "destination" field. Fianlly, do this field calculation to your "code_node" field: [origin]&[destination]






    share|improve this answer
























    • Is there anyway to do this using a spatial join instead of creating new temporary files?

      – Sarah
      Feb 28 '14 at 14:42











    • I am not %100 sure on that but I think we need the starting/ending points anyway.

      – Arash
      Feb 28 '14 at 17:00














    4












    4








    4







    Use Feature Vertices To Points to get the START points from the line shapefile. Do the same for END points. Name the resulted layers "start" and "end". Then use Spatial Join to join these resulted layers to your node layer separately (Target features: "start" and "end" layers, Join feature: your node layer, JOIN_ONE_TO_ONE, Match Option: Intersect). Name the resulting layers "startJoin" and "endJoin". Add a new field "origin" to your line layer (with the same properties as your "code_1" field, I suggest TEXT format). Join your line layer to "startJoin" (match FID to ORIG_FID) and by field calculator copy "code_1" in the "origin" field. Add another field "destination" to your line layer and do the same (you may want to remove the existing join before doing this) for "endJoin" and get the "code_1" into "destination" field. Fianlly, do this field calculation to your "code_node" field: [origin]&[destination]






    share|improve this answer













    Use Feature Vertices To Points to get the START points from the line shapefile. Do the same for END points. Name the resulted layers "start" and "end". Then use Spatial Join to join these resulted layers to your node layer separately (Target features: "start" and "end" layers, Join feature: your node layer, JOIN_ONE_TO_ONE, Match Option: Intersect). Name the resulting layers "startJoin" and "endJoin". Add a new field "origin" to your line layer (with the same properties as your "code_1" field, I suggest TEXT format). Join your line layer to "startJoin" (match FID to ORIG_FID) and by field calculator copy "code_1" in the "origin" field. Add another field "destination" to your line layer and do the same (you may want to remove the existing join before doing this) for "endJoin" and get the "code_1" into "destination" field. Fianlly, do this field calculation to your "code_node" field: [origin]&[destination]







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Feb 5 '14 at 3:09









    ArashArash

    73531330




    73531330













    • Is there anyway to do this using a spatial join instead of creating new temporary files?

      – Sarah
      Feb 28 '14 at 14:42











    • I am not %100 sure on that but I think we need the starting/ending points anyway.

      – Arash
      Feb 28 '14 at 17:00



















    • Is there anyway to do this using a spatial join instead of creating new temporary files?

      – Sarah
      Feb 28 '14 at 14:42











    • I am not %100 sure on that but I think we need the starting/ending points anyway.

      – Arash
      Feb 28 '14 at 17:00

















    Is there anyway to do this using a spatial join instead of creating new temporary files?

    – Sarah
    Feb 28 '14 at 14:42





    Is there anyway to do this using a spatial join instead of creating new temporary files?

    – Sarah
    Feb 28 '14 at 14:42













    I am not %100 sure on that but I think we need the starting/ending points anyway.

    – Arash
    Feb 28 '14 at 17:00





    I am not %100 sure on that but I think we need the starting/ending points anyway.

    – Arash
    Feb 28 '14 at 17:00













    0














    I like the approach suggested by @Arash, but this creates 3 additional files, which really adds up if you have a large network and need to check this regularly. Here's my solution using python.



    The geometric network build forces the X,Y of the nodes and the pipe ends to be coincident. You can access these locations with the shape tokens in arcpy cursors and match them. The shape tokens for lines return an array of the vertices in the order that they were drawn. In my network, the draw order of the pipes is heavily QA'd because we use this to set the flow directions. So, the first vertex is the start of the pipe, and the last vertex is the end of the pipe.



    Reference: ASSETID = id of pipe, UNITID = node id at start of pipe, UNITID2 = node id at end of pipe.



    nodes = "mergeNodes"
    pipes = "SEWER_1"

    nodeDict = {}
    pipeDict = {}

    #populate node dictionary with X,Y as the key and node ID as the value
    for node in arcpy.da.SearchCursor(nodes, ["UNITID", "SHAPE@XY"]):
    nodeDict[(node[1][0], node[1][1])] = node[0]

    #populate pipe dictionary with pipe ID as the key and list of X,Y as values
    #vertices populated in the order that the line was draw
    #so that [0] is the first vertex and [-1] is the final vertex
    for pipe in arcpy.da.SearchCursor(pipes, ["ASSETID", "SHAPE@"]):
    for arrayOb in pipe[1]:
    for point in arrayOb:
    if pipe[0] in pipeDict:
    pipeDict[pipe[0]].append((point.X, point.Y))
    else:
    pipeDict[pipe[0]] = [(point.X, point.Y)]

    #populate UNITID with the first vertex of the line
    #populate UNITID2 with the final vertex of the line
    with arcpy.da.UpdateCursor(pipes, ["ASSETID", "UNITID", "UNITID2"]) as cur:
    for pipe in cur:
    if pipeDict[pipe[0]][0] in nodeDict:
    pipe[1] = nodeDict[pipeDict[pipe[0]][0]]
    if pipeDict[pipe[0]][-1] in nodeDict:
    pipe[2] = nodeDict[pipeDict[pipe[0]][-1]]
    cur.updateRow(pipe)





    share|improve this answer




























      0














      I like the approach suggested by @Arash, but this creates 3 additional files, which really adds up if you have a large network and need to check this regularly. Here's my solution using python.



      The geometric network build forces the X,Y of the nodes and the pipe ends to be coincident. You can access these locations with the shape tokens in arcpy cursors and match them. The shape tokens for lines return an array of the vertices in the order that they were drawn. In my network, the draw order of the pipes is heavily QA'd because we use this to set the flow directions. So, the first vertex is the start of the pipe, and the last vertex is the end of the pipe.



      Reference: ASSETID = id of pipe, UNITID = node id at start of pipe, UNITID2 = node id at end of pipe.



      nodes = "mergeNodes"
      pipes = "SEWER_1"

      nodeDict = {}
      pipeDict = {}

      #populate node dictionary with X,Y as the key and node ID as the value
      for node in arcpy.da.SearchCursor(nodes, ["UNITID", "SHAPE@XY"]):
      nodeDict[(node[1][0], node[1][1])] = node[0]

      #populate pipe dictionary with pipe ID as the key and list of X,Y as values
      #vertices populated in the order that the line was draw
      #so that [0] is the first vertex and [-1] is the final vertex
      for pipe in arcpy.da.SearchCursor(pipes, ["ASSETID", "SHAPE@"]):
      for arrayOb in pipe[1]:
      for point in arrayOb:
      if pipe[0] in pipeDict:
      pipeDict[pipe[0]].append((point.X, point.Y))
      else:
      pipeDict[pipe[0]] = [(point.X, point.Y)]

      #populate UNITID with the first vertex of the line
      #populate UNITID2 with the final vertex of the line
      with arcpy.da.UpdateCursor(pipes, ["ASSETID", "UNITID", "UNITID2"]) as cur:
      for pipe in cur:
      if pipeDict[pipe[0]][0] in nodeDict:
      pipe[1] = nodeDict[pipeDict[pipe[0]][0]]
      if pipeDict[pipe[0]][-1] in nodeDict:
      pipe[2] = nodeDict[pipeDict[pipe[0]][-1]]
      cur.updateRow(pipe)





      share|improve this answer


























        0












        0








        0







        I like the approach suggested by @Arash, but this creates 3 additional files, which really adds up if you have a large network and need to check this regularly. Here's my solution using python.



        The geometric network build forces the X,Y of the nodes and the pipe ends to be coincident. You can access these locations with the shape tokens in arcpy cursors and match them. The shape tokens for lines return an array of the vertices in the order that they were drawn. In my network, the draw order of the pipes is heavily QA'd because we use this to set the flow directions. So, the first vertex is the start of the pipe, and the last vertex is the end of the pipe.



        Reference: ASSETID = id of pipe, UNITID = node id at start of pipe, UNITID2 = node id at end of pipe.



        nodes = "mergeNodes"
        pipes = "SEWER_1"

        nodeDict = {}
        pipeDict = {}

        #populate node dictionary with X,Y as the key and node ID as the value
        for node in arcpy.da.SearchCursor(nodes, ["UNITID", "SHAPE@XY"]):
        nodeDict[(node[1][0], node[1][1])] = node[0]

        #populate pipe dictionary with pipe ID as the key and list of X,Y as values
        #vertices populated in the order that the line was draw
        #so that [0] is the first vertex and [-1] is the final vertex
        for pipe in arcpy.da.SearchCursor(pipes, ["ASSETID", "SHAPE@"]):
        for arrayOb in pipe[1]:
        for point in arrayOb:
        if pipe[0] in pipeDict:
        pipeDict[pipe[0]].append((point.X, point.Y))
        else:
        pipeDict[pipe[0]] = [(point.X, point.Y)]

        #populate UNITID with the first vertex of the line
        #populate UNITID2 with the final vertex of the line
        with arcpy.da.UpdateCursor(pipes, ["ASSETID", "UNITID", "UNITID2"]) as cur:
        for pipe in cur:
        if pipeDict[pipe[0]][0] in nodeDict:
        pipe[1] = nodeDict[pipeDict[pipe[0]][0]]
        if pipeDict[pipe[0]][-1] in nodeDict:
        pipe[2] = nodeDict[pipeDict[pipe[0]][-1]]
        cur.updateRow(pipe)





        share|improve this answer













        I like the approach suggested by @Arash, but this creates 3 additional files, which really adds up if you have a large network and need to check this regularly. Here's my solution using python.



        The geometric network build forces the X,Y of the nodes and the pipe ends to be coincident. You can access these locations with the shape tokens in arcpy cursors and match them. The shape tokens for lines return an array of the vertices in the order that they were drawn. In my network, the draw order of the pipes is heavily QA'd because we use this to set the flow directions. So, the first vertex is the start of the pipe, and the last vertex is the end of the pipe.



        Reference: ASSETID = id of pipe, UNITID = node id at start of pipe, UNITID2 = node id at end of pipe.



        nodes = "mergeNodes"
        pipes = "SEWER_1"

        nodeDict = {}
        pipeDict = {}

        #populate node dictionary with X,Y as the key and node ID as the value
        for node in arcpy.da.SearchCursor(nodes, ["UNITID", "SHAPE@XY"]):
        nodeDict[(node[1][0], node[1][1])] = node[0]

        #populate pipe dictionary with pipe ID as the key and list of X,Y as values
        #vertices populated in the order that the line was draw
        #so that [0] is the first vertex and [-1] is the final vertex
        for pipe in arcpy.da.SearchCursor(pipes, ["ASSETID", "SHAPE@"]):
        for arrayOb in pipe[1]:
        for point in arrayOb:
        if pipe[0] in pipeDict:
        pipeDict[pipe[0]].append((point.X, point.Y))
        else:
        pipeDict[pipe[0]] = [(point.X, point.Y)]

        #populate UNITID with the first vertex of the line
        #populate UNITID2 with the final vertex of the line
        with arcpy.da.UpdateCursor(pipes, ["ASSETID", "UNITID", "UNITID2"]) as cur:
        for pipe in cur:
        if pipeDict[pipe[0]][0] in nodeDict:
        pipe[1] = nodeDict[pipeDict[pipe[0]][0]]
        if pipeDict[pipe[0]][-1] in nodeDict:
        pipe[2] = nodeDict[pipeDict[pipe[0]][-1]]
        cur.updateRow(pipe)






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 17 mins ago









        PriscillaPriscilla

        818414




        818414






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f85082%2fhow-to-assign-node-ids-to-links-in-a-network%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            (145452) 2005 RN43 Классификация | Примечания | Ссылки |...

            Щит и меч (фильм) Содержание Названия серий | Сюжет |...

            Энтрерриос (город) Содержание История | Географическое...