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 multipart polyline shapefile containing a large number of lines, some of which are broken by gaps and some of which have more than one start and end (by mistake - see attached). I need to have a multipart shapefile output, which contains only unbroken lines with one start and one end. Is there a way to identify these errors (can't seem to do it with the the topology rules in Arc)? Once identified they are easy to fix manually.

Thanks.

share|improve this question
1  
attachment is not visible..can you post it to dropbox or somewhere else if you can't add image here? –  vinayan Jan 17 '13 at 12:43
add comment

2 Answers

If the polylines are unbroken then they should only be a single part. You could use Python to create a to loop through each record in the shapefile and get the part count of each feature. If the part count is greater than 1 then the feature should have multiple start and end points or be disconnected.

UPDATE:

import arcpy

inputSHP = r"path/to/input/shapefile"
outputSHP = r"path/to/output/shapefile" # This shapefile should already be created with all the properties of the input shapefile (use input shapefile as a template)

fields = arcpy.ListFields(inputSHP) # This gets all the fields in the input shapefile into a python list

outrows = arcpy.InsertCursor(outputSHP) # This allows you to insert features into the output shapefile

rows = arcpy.SearchCursor(inputSHP) # This reads each feature in the input shapefile one at a time

for row in rows: # Loop through each feature in the input shapefile

    if row.SHAPE.partCount == 1: # Determine if geometry has more than one part

        newrow = outrows.newRow() # Create new feature in output shapefile

        for field in fields: # Loop through fields in input shapefile (these should be exactly the same as in the output shapefile)

            newrow.setValue(field.name, row.getValue(field.name) # Set the value of each field in the output shapefile feature to that field in the of the input shapefile feature

        outrows.insertRow(newrow) # Save the new feature into the output shapefile

        del newrow # Memory management (delete the new row object)

    del row # Memory management (delete the input row object)
del rows, outrows # Memory management (delete the cursor objects)
share|improve this answer
    
Thank you - it sounds as though that would do it. Unfortunately I have almost no experience with Python. Do you know of anywhere I could find a similar example script? –  Rob Jan 18 '13 at 12:57
    
I added a code example to get you started. Check out the ArcPy Site Package and the ArcGIS Python help to get some more background. resources.arcgis.com/en/help/main/10.1/#/What_is_Python/… –  Brian Jan 18 '13 at 15:32
add comment

These are the steps I would use:

add field TmpID as long
calculate tmpID = Objectid (to preserve the ObjectID)
run tool MultipartToSinglepart
run tool UnsplitLine
run tool Frequency on tmpID (this produces a feature count for each tmpID)
join the frequency table to your polylines (join on polyline.objectid = frequency.tmpid)
select "Frequency" > 1

share|improve this answer
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.