Repeating and Overlapping Line Features.....

1542
6
05-16-2013 05:50 AM
JamesReed1
Occasional Contributor
I have a feature class (polylines) that evidently has overlapping lines in it. Is there a fast way to delete the repeating features? Up to this point I have been selecting a vertices and moving it to see the lines behind it.
0 Kudos
6 Replies
MarkBoucher
Occasional Contributor III
Topology tools are what I use for this type of thing. For this, the data needs to be in a geodatabase. Then you create the topology in that geodatabase and then create rules like "must not overlap" and "must not have gaps". Then there is a topology tool bar that makes these fixes easier.

There is another process that may do what you want. I've heard of it only recently, but have not had to use it.
0 Kudos
DaleHoneycutt
Occasional Contributor III
This might help: use the Intersect tool.  For the input features, add your line feature class TWICE.  Yes, twice -- you're going to intersect the lines with themselves.  If you enter it once, you'll get empty output.

The output will have more features than the input.  When segments of a line segments overlap each other, a new line (w/o overlap) is created in the output.  Here's a picture of the result:

[ATTACH=CONFIG]24384[/ATTACH]

I'm not sure what you want to do next.  If you want to stitch the lines back together, use Dissolve.  Dissolve on one of the FID_ fields and specify that you want multipart features created.

(I thought about this a bit more; if you want to stitch the lines back together, you don't need to use the Intersect tool -- you can use Feature To Line tool instead.  The input is your line features.  The output will be a bunch of line fragments with the FIDs carried through. You then Dissolve on the FID and create multipart features.  In theory, Feature To Line should be much quicker than Intersect since it doesn't have to assemble topology.)
0 Kudos
T__WayneWhitley
Frequent Contributor
Fascinating... I thought that maybe this technique below was worthy mention and it's related to something else I'm working on -- and actually I was itching to take this for a test drive, using geometry as input for gp tools. I was interested in using one of the overlap_type selection options called 'SHARE_A_LINE_SEGMENT_WITH' provided with Select Layer By Location, and it tested successfully on a test dataset to select lines partially or fully overlapping (a subject endpoint does not have to be coincident with a vertex on an overlap candidate) - what's more, 'touching' or 'crossing' line segments are ignored (I think the INTERSECT overlap_type option would work for this). Success! - in this case, the topology implementation wasn't necessary, which in itself can be processing intensive.
So keep in mind the below is mainly for demo purposes, done in an IDLE session - pardon the inefficiency, it's not been adapted for a tool but go ahead if so desired (if one doesn't already exist). I suppose I should state the 'key' here is the interesting line I hope I properly made in bold red font within the code section below:
>>> arcpy.env.overwriteOutput = True
>>> rows = arcpy.SearchCursor(fc)
>>> for row in rows:
               feat = row.shape
               result1 = arcpy.MakeFeatureLayer_management(fc, 'testlyr')
               result2 = arcpy.SelectLayerByLocation_management('testlyr', 'SHARE_A_LINE_SEGMENT_WITH', feat)               count = int(arcpy.GetCount_management('testlyr').getOutput(0))
               rowsL = arcpy.SearchCursor('testlyr')
               print 'The test subject OBJECTID: ' + str(row.OBJECTID)
               print '...the selection count (not including self): ' + str(count - 1)
               for rowL in rowsL:
                     if rowL.OBJECTID != row.OBJECTID:
                           print '...overlapping segment OBJECTID: ' + str(rowL.OBJECTID)
               print '\n'
 


The test subject OBJECTID: 4
...the selection count (not including self): 1
...overlapping segment OBJECTID: 12


The test subject OBJECTID: 8
...the selection count (not including self): 2
...overlapping segment OBJECTID: 11
...overlapping segment OBJECTID: 16


The test subject OBJECTID: 9
...the selection count (not including self): 0


The test subject OBJECTID: 10
...the selection count (not including self): 0


The test subject OBJECTID: 11
...the selection count (not including self): 2
...overlapping segment OBJECTID: 8
...overlapping segment OBJECTID: 16


The test subject OBJECTID: 12
...the selection count (not including self): 1
...overlapping segment OBJECTID: 4


The test subject OBJECTID: 13
...the selection count (not including self): 0


The test subject OBJECTID: 14
...the selection count (not including self): 0


The test subject OBJECTID: 16
...the selection count (not including self): 2
...overlapping segment OBJECTID: 8
...overlapping segment OBJECTID: 11


The test subject OBJECTID: 17
...the selection count (not including self): 1
...overlapping segment OBJECTID: 18


The test subject OBJECTID: 18
...the selection count (not including self): 1
...overlapping segment OBJECTID: 17

>>>


Enjoy,
Wayne
0 Kudos
T__WayneWhitley
Frequent Contributor
I realize the output I included after the code block above may not make sense to you since there's no context, so I am attaching the small test shapefile I ran this snippet on...  If you want to try it out, change the 'fc' variable to the full pathname of the location to which you save the unzipped shapefile.  Then it would help if you observed the line segment overlaps in ArcMap, etc.

Sorry if I wasn't so clear on that at 1st - I would think if you are really intent on using something like this, you'd rather have something to flag features via a field value in order to examine the overlapping line segments before deleting.

Anyway, hope this interests you...

-Wayne
0 Kudos
JamesReed1
Occasional Contributor
Topology tools are what I use for this type of thing. For this, the data needs to be in a geodatabase. Then you create the topology in that geodatabase and then create rules like "must not overlap" and "must not have gaps". Then there is a topology tool bar that makes these fixes easier.

There is another process that may do what you want. I've heard of it only recently, but have not had to use it.


Do I need to make a copy of the feature class before doing this? Is there a chance I will mess the file up and can't go back? Thanks for the help.
0 Kudos
RichardFairhurst
MVP Honored Contributor
Do I need to make a copy of the feature class before doing this? Is there a chance I will mess the file up and can't go back? Thanks for the help.


Yes, it is wise to have a back up, especially when first testing out and learning how topology behaves.  Corruption is not so much of a problem as much as failing to realize how your choices using the topology tools affect your features, because you are not used to them.  Topology will permanently alter your data, but it does it within an edit session.  As long as you catch problems before saving and exiting the edit session you can undo them or prevent them from becoming permanent, but if you missed a problem after committing the edits you cannot go back without some kind of backup.  Once you have everything working well and understand the topology workflow options and the critical quality check steps you need to do, you could choose to delete all back ups and work with the topology controlled feature class alone.
0 Kudos