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:
- Begin from the first row in Hydro feature class attribute table and get its ID
- Insert this ID into "From" field in "FromTo" table
- Get ID(s) of line(s) which intersect(s) first line (e.g. second line intersect first line)
- Inset ID into "To" field in FromTo table
For second loop
Get ID of second row in Hydro feature class attribute table
Insert this ID into "From" field in "FromTo" table
Get IDs of lines which intersect second line (e.g. first and third lines intersect second line)
Inset IDs into "To" field in FromTo table
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– PolyGeo ♦2012年10月04日 22:20:51 +00:00Commented Oct 4, 2012 at 22:20
-
@PolyGeo: No, just trying to get connectivity of the network by creating this FromTo table.user10727– user107272012年10月04日 23:07:28 +00:00Commented Oct 4, 2012 at 23:07
2 Answers 2
See arcpy.SearchCursor to iterate through a table or featureclass
See arcpy.InsertCursor to insert a value into a table or featureclass, and arcpy.UpdateCursor to edit an existing value
See Select By Location to find features based on spatial relationships
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:
- Intersect with just the one input feature class - works for all license levels
- Tabulate Intersection if you have ArcGIS 10.1 for Desktop Advanced