ArcGIS/ArcPy – Creating Lines from Polygon Borders with Attributes

arcgis-desktoparcpylinepolygon

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?

Best Answer

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:

Parameters

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

Related Question