I have line feature class of a river network and “FromTo” table. Lines are dissolved so they are not segmented from junctions. I need to write a Python script in ArcGIS to do following:

  1. Begin from the first row in Hydro feature class attribute table and get its ID
  2. Insert this ID into “From” field in “FromTo” table
  3. Get ID(s) of line(s) which intersect(s) first line (e.g. second line intersect first line)
  4. Inset ID into “To” field in FromTo table

For second loop

  1. Get ID of second row in Hydro feature class attribute table

  2. Insert this ID into “From” field in “FromTo” table

  3. Get IDs of lines which intersect second line (e.g. first and third lines intersect second line)

  4. Inset IDs into “To” field in FromTo table

  5. So on…

Perhaps, you show a different way in order to get the same result by Python

enter image description here

  • Are you trying to do Strahler stream ordering with vector data? This describes the raster alternative resources.arcgis.com/en/help/main/10.1/index.html#//…
    – PolyGeo
    Commented Oct 4, 2012 at 22:20
  • @PolyGeo: No, just trying to get connectivity of the network by creating this FromTo table.
    – user10727
    Commented Oct 4, 2012 at 23:07

2 Answers 2


Between those commands you can do most of what you're asking for.

Update: As per Accessing data using cursors there is now a new data access module (arcpy.da). The previously existing cursors are still functional and valid; however, the new arcpy.da cursors include significantly faster performance


Since you appear to be just wanting to know where your lines intersect, and which lines intersect at those locations, before going to Python, you may want to try:

  1. Intersect with just the one input feature class - works for all license levels
  2. Tabulate Intersection if you have ArcGIS 10.1 for Desktop Advanced

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.