4

So I have a polyline shapefile showing the border of a city, however there are multiple gaps in the shapefile ranging from ~2m to well over 1km that are almost impossible to see when viewing the area even at a large scale. I am trying to generate a polygon using this outline in ArcGIS, however due to the breaks I cannot. Is there any way to at least identify which line segments are not joined? I attempted this solution in python with no luck.

1

5 Answers 5

5

You can easily identify polylines that are not connected to other polylines using the feature vertices to points tool with dangle option selected. This does require a higher license level, but as you do not state which version you have I will assume you have it.

The output will be a point dataset which you could scan manually to identify where the gaps are and then correct the problem manually.

3
  • Hmmm I tried this and Arc outputted an empty feature class, despite the fact that there are definitely breaks in the shapefile, any idea why?
    – purelyp93
    Commented Jun 2, 2015 at 22:26
  • Is the data multi-part? Try running it through a multi-part-to-single-part tool first?
    – Hornbydd
    Commented Jun 2, 2015 at 22:49
  • Aha! After running the multipart to singlepart tool, I had to run the output through the "Unsplit Lines" tool, which merges all the polylines together. From there I ran the feature vertices to points tool which showed all the breaks in the file.
    – purelyp93
    Commented Jun 3, 2015 at 18:09
3

Depending on how accurate the rest of your points need to be, you can simply set the XY Tolerance of the Feature To Polygon tool to 2 or 3 meters. This will fill in your gaps for you, but it will also create polygons whose vertices differ from the original input vertices by 2 to 3 meters.

2
  • FeatureToPolygon requires ArcInfo, so it may not be available for everyone.
    – nagytech
    Commented Jun 2, 2015 at 9:50
  • I forgot to mention that in addition to the ~2m breaks, there are other, larger breaks around 15-20m that will need to be re-digitized once the missing section is located, so the Feature to Polygon tool cannot be used in this case.
    – purelyp93
    Commented Jun 2, 2015 at 22:27
1

You could build topology rules which would identify ends not joining.

0

Here's a script to add lines in breaks of lines. It creates dangle points, figures out their XY, checks for those that are within a certain distance of each other (the maxDist variable), and draws a line between those that are. It creates a new output with the same name as your input, plus "_connected". A workspace geodatabase and workspace folder are used for intermediate outputs.

##Local variables

#Input feature class
inFC = r"C:\Users\e1b8\Desktop\ScriptOutputs\OutData.gdb\Sample_FC"

#Max Distance
maxDist = "2 Meters"

#Workspace GDB
workspaceGDB = r"C:\temp\Workspace.gdb"
#Workspace folder
workspace = r"C:\temp"

#-------------

from arcpy import *
import os

env.overwriteOutput = True

#List for cleanup
garbage = []

print "feature vertices to points"
#Feature vertices to points
pointFC = os.path.join (workspaceGDB, "points")
FeatureVerticesToPoints_management (inFC, pointFC, "DANGLE")
#Add point FC to garbage list
garbage += [pointFC]

print "determining XY coordiantes"
#Get XY coordinates by OID
Xdi = {}
Ydi = {}
cursor = da.SearchCursor (pointFC, ["OID@", "SHAPE@X", "SHAPE@Y"])
for row in cursor:
    Xdi[row[0]] = row[1]
    Ydi[row[0]] = row[2]

print "point distance analysis"
#Point distance analysis
outTable = os.path.join (workspace, "table.dbf")
PointDistance_analysis (pointFC, pointFC, outTable, maxDist)
#Add table to garbage list
garbage += [outTable]

#Get spatial reference of input feature class
SR = Describe (inFC).spatialReference

print "Creating empty line fc"
#Empty feature layer for new lines
addedLinesFc = os.path.join (workspaceGDB, "newLines")
CreateFeatureclass_management (workspaceGDB,
                               "newLines",
                               "POLYLINE",
                               inFC, spatial_reference = SR)

#Add new line fc to garbage
garbage += [addedLinesFc]

#list of combos
combos = []

#Iterate table
print "iterating lines"
cursor = da.SearchCursor (outTable, ["INPUT_FID", "NEAR_FID"])
for row in cursor:
    combo = sorted([row[0], row[1]])
    #skip points if already used to make a line
    if combo in combos:
        continue
    combos += [combo]
    print row[0], row[1]
del cursor

print "inserting new features"
#insertcursor new lines
cursor = da.InsertCursor (addedLinesFc, "SHAPE@")
#iterate combos
for combo in combos:

    array = arcpy.Array ([arcpy.Point (Xdi[combo[0]], Ydi[combo[0]]),
                         arcpy.Point (Xdi[combo[1]], Ydi[combo[1]])])
    polyline = arcpy.Polyline(array)
    cursor.insertRow ([polyline])
del cursor

#Merge lines
print "Creating final output"
mergeFC = inFC + "_connected"
Merge_management ([inFC, addedLinesFc], mergeFC)
print "Created:", mergeFC

#Clean up

for trash in garbage:
    Delete_management (trash)

Let me know if anything doesn't make sense!

3
  • Unfortunately, my shapefile does not seem to work with the "Feature Verticies to points" tool. Even when I run the tool on it's own, it generates an empty class.
    – purelyp93
    Commented Jun 3, 2015 at 17:29
  • Can you import it into a file geodatabase? Also you can try the RepairGeometry too on it. Commented Jun 3, 2015 at 17:33
  • Yep, I imported it into a file geodatabase, and ran RepairGeomtry on it with no change. Just to check I ran Feature Vertices to Points again on the new geodatabase file and it still outputted and empty point class. Could it be that the original file is corrupted or something?
    – purelyp93
    Commented Jun 3, 2015 at 17:52
0

A workflow is:

  1. Create a GDB.
  2. In the GDB make a Feature Dataset.
  3. place your line file in the Feature Dataset
  4. Create a topology in the Feature Dataset
  5. Add the dangle rule to the topology
  6. drag topology into ArcMap
  7. Open Topology toolbar
  8. use topology error inspector to fix errors
  9. run Feature to Polygon tool.

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.