8

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?

2 Answers 2

6

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.

2
  • unfortunately, there is no field that is useful enough to run the Dissolve Tool Commented Nov 4, 2011 at 14:19
  • 2
    then create a new field (short int) and dissolve on it's default (0)
    – Brad Nesom
    Commented Nov 4, 2011 at 14:34
5

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.

1
  • Couldn't have said it better. +1 Commented Nov 7, 2011 at 9:34

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.