I have a shapefile of polygons that border each other perfectly, each with a numerical attriubte. I'd to create a shapefile of lines, where every line is created from the border between two polygons, and those lines have the attributes of both the polygons that they border.

How do I do this using ArcGIS for Desktop?

2 Answers 2


You can do this with the Intersect tool. Normally, performing an intersect with polygons will only return the overlapping area. But if you change the output_type from INPUT to LINE, then you can get just the collinear borders between polygons.

If this is our input:

Input polygons

And we change the output_type parameter:


We get the green lines as output:

Output lines

The output contains two line features for every border segment. To collapse this down to one feature per border segment, you'll want to run Dissolve with the multi_part parameter set to SINGLE_PART. Then, run a Spatial Join with your dissolved lines as the target_features, the intersected lines as the join_features, your field_mapping setup with two fields for every input field (one using the FIRST merge type and the other using the LAST merge type), and the match_option set to ARE_IDENTICAL_TO. Your output attribute table will look like the following:

Attribute table


You can do this with python if you are at least at ArcGIS 10.1. If you have ArcInfo, you can use the Feature to Line tool. Otherwise, you can use this simple script. This script does not support true curves though. The resulting lines, if topologically correct should overlap then you can run an intersect of this line fc on itself to find the boundaries that overlap, i.e. the border lines.

import arcpy
import os
arcpy.env.overwriteOutput = True

def polys_to_lines(fc, new_fc):

    path, name = os.path.split(new_fc)
    arcpy.CreateFeatureclass_management(path, name, 'POLYLINE', fc, sm, sm, fc)

    fields = [f.name for f in arcpy.ListFields(new_fc)
              if f.type not in ('OID', 'Geometry')]

    # get attributes
    with arcpy.da.SearchCursor(fc, ['SHAPE@'] + fields) as rows:
        values = [(r[0].boundary(),) + tuple(r[1:]) for r in rows]

    # insert rows
    with arcpy.da.InsertCursor(new_fc, ['SHAPE@'] + fields) as irows:
        for vals in values:
    print 'Created: "{0}"'.format(name)
    return new_fc

if __name__ == '__main__':

    fc = r'C:\TEMP\parcel_test.shp'
    new = r'C:\TEMP\parcel_Linetest2.shp'
    polys_to_lines(fc, new)

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.