Can't get geometry.overlaps etc to work with Polylines

Discussion created by robintw147 on Jan 21, 2011
Latest reply on Feb 2, 2011 by kimo

I am trying to calculate which polylines in my dataset overlap with each other, and can't seem to get it to work. The basic procedure that I'm using is to loop through my features, and then have a second inner loop that loops through the features again and finds out which ones the first feature overlaps with. However, I end up with nothing showing as overlapping (even though some of my features are definitely overlapping). I tried this with some of the other geometry methods such as touches, within, crosses etc, and they also seem to give strange results. For example, I get nothing showing as touching, overlapping, crossing etc, but then also nothing showing as disjoint - which doesn't seem to make sense.

My python code is below, it's quite possible that I've made an elementary error:

import arcpy
input_lines = "D:\\Data\\DunesGIS\\TestOverlaps.shp"

rows = arcpy.SearchCursor(input_lines)

shape_name = arcpy.Describe(input_lines).shapeFieldName

for row in rows:
    shape = row.getValue(shape_name)
    comparison_rows = arcpy.SearchCursor(input_lines)
    for comparison in comparison_rows:
        comparison_shape = row.getValue(shape_name)
        #print comparison_shape
        if shape.overlaps(comparison_shape):
            print "FOUND IT!!"

    del comparison_rows
print "Done"

del rows