Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

I have a polygon layer of water reservoirs and a polyline layer of canals.

In my data, some canals are originating from reservoirs, and leading to other canals. On the other hand there are some canals that are isolated or not connected to anything. (How this came about is story for another day)

I need to delete the isolated canals and those canal networks(i.e. connected set of canals) that are not connected to a reservoir.

I assume that i will have to use some kind of network tracing, but I am not sure where to start.

I have ArcGIS desktop, along with Network Analyst to solve this task.

How would you go about this task?

share|improve this question
add comment

2 Answers 2

I'm not sure exactly what your canal shapefile looks like, but here's how I would do that without using Network Analyst:

In the likely case that your Canals.shp polylines are split into separate but connected segments, use Dissolve to unsplit them. Then run Select by Location, finding features in Canals.shp that INTERSECT or BOUNDARY_TOUCHES with Reservoirs.shp.

share|improve this answer
    
unfortunately, there is no field that is useful enough to run the Dissolve Tool –  Devdatta Tengshe Nov 4 '11 at 14:19
2  
then create a new field (short int) and dissolve on it's default (0) –  Brad Nesom Nov 4 '11 at 14:34
add comment

I would approach this as two separate problems. First, the individual line segments must be dissolved into connected components; just dissolving all of them on a default value won't work. This is a graph theory problem, and what we want are the "connected component sub graphs".

I'm sure there's a way to hack this with network analyst, but my preference would be to treat it like the graph problem it is; don't reinvent the wheel, just install the excellent Networkx python module and try the following:

from networkx import Graph, connected_components
G = Graph()
# iterate through your feature class and build a graph
for row in featureclass:
    # we need a unique representation for each edges start and end points
    start = row.shape.getpart()[0]
    end = row.shape.getpart()[-1]
    G.add_edge(start,end,oid=row.oid)

# get the connected components
Components = connected_components(G)

# we now have a "list of lists" containing edges grouped by their component
# there's several ways to apply this to the feature class...eg
for i, connected in enumerate(Components):
    # assign id = i to the group by writing it to a field for all members 
    # of that component (the row oid is an attribute of the edge)

Second step would be the dissolve and select by location as suggested by dmahr

I've used a similar technique many times successfully. Graph theory is awesome and solves many GIS problems, and Networkx is a great tool to implement this in python.

share|improve this answer
    
thanks. I'll try it at work on Tuesday! –  Devdatta Tengshe Nov 6 '11 at 15:48
    
Couldn't have said it better. +1 –  Allan Adair Nov 7 '11 at 9:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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