Hi, this is not a question but a way to trace a network on ArcGis 10 (trace tool is only available as of 10.1), provided it is topologically correct and the direction of the network is correct.
Basically
- Select the first segment of interest, in my case i did it with select by location.
- Extract vertex: if you are going upwards up the network then choose START vertex, if you are going downwards then choose END vertex.
- Create the following loop:
Select next group of segments based on the extracted vertex; carefull it should be with the option BOUNDARY_TOUCH.
Create feature/shape based on this selection
Extract vertex again.
So, solved the looping control quite easily and fast, so here goes the whole deal (not such a big deal):
# Note: In my case I selected my first segment as being the one that intersects a given point. Of course you change this according to your needs.
arcpy.MakeFeatureLayer_management(your_point, 'your_point_lyr')
arcpy.MakeFeatureLayer_management(your_network, 'your_network_lyr')
arcpy.SelectLayerByLocation_management('your_network_lyr', 'INTERSECT', 'your_point_lyr')
arcpy.FeatureVerticesToPoints_management('your_network_lyr',start_vertex, "START")
print 'done start vertex'
# It is important to use BOUNDARY_TOUCHES, only then will it choose all segments touching that point. If you use INTERSECT it will only choose one segment.
# Save the new network outside the loop.
segment_river_before = 0
segment_river_after = 1
n = 0
while segment_river_after != segment_river_before:
n +=1
segment_river_before = int(arcpy.GetCount_management(your_network_lyr).getOutput(0))
arcpy.MakeFeatureLayer_management(start_vertex, 'start_v_lyr')
arcpy.SelectLayerByLocation_management('your_network_lyr', 'BOUNDARY_TOUCHES', 'start_v_lyr')
segment_river_after = int(arcpy.GetCount_management(your_network_lyr).getOutput(0))
arcpy.FeatureVerticesToPoints_management('your_network_lyr, start_vertex, "START")
print 'No. of loops made, No. of river segments before and after', n, segment_river_before, segment_river_after
arcpy.CopyFeatures_management("net_lyr", new_net, "", "0", "0", "0")
print 'Yeiiiii, it worked'