I have a shapefile of United States counties. Suppose I am interested in all counties in Georgia that border North Carolina and all counties in North Carolina that border Georgia. And, in particular, I'm interested in knowing which Georgia counties border which North Carolina counties. For example, suppose Rabun County, Georgia is along this border. I want to know which is the county that borders Rabun in North Carolina.

My ultimate goal is as follows: I believe that Rabun, Georgia borders both Clay, North Carolina and Macon, North Carolina. I would like to then create two files. One would be the line segment of the border segment between Rabun and Clay. The other would be the line segment of the border between Rabun and Macon. I know line segments can be isolated between two bordering geographic units by using intersect. For example, if I were to intersect Rabun and Clay as two separate files, I would isolate the line segment that is their shared border.

I would like to repeat this procedure for every other pair of counties along the Georgia and North Carolina (in addition to other borders, which is why I would like to streamline the process).

How do I streamline this process?

I know how to do it by brute force, but I realize it can take awhile or be inaccurate. I was just wondering if there is a more efficient way to do this.

I use ArcMap 10.1.


3 Answers 3


Share a line segment with (option)

enter image description here

With this method, the source and target features are considered as sharing a line segment if their geometries have at least two contiguous vertices in common.

The source and target features must be either lines or polygons.

The highlighted cyan features are selected because they share a line segment with a red feature.


to Automate the process use ModelBuilder http://resources.arcgis.com/en/help/main/10.1/index.html#//002w00000001000000


Programatically you could use a Cursor with Select By location.

The output is really up to you as I'm not sure how you're planning on using the information. You could append all of the county names in a list and add it to a field. You could create a related table and add a record for each individual bordering county.

In order to select the counties of interest with arcpy build your code around this pseudo code:

  1. Make a feature layer of all NC counties.
  2. Make a feature layer of all GA counties.
  3. Using a Search Cursor on the NC counties feature layer, loop through each polygon.
    1. Select GA counties from feature layer that share a line segment with the current NC county.
    2. Decide what you want to do with these counties (a few examples above)

Hopefully this should get you started:

import arcpy

stateField = '' # Enter the name of the field storing state name
states = ["Georgia", "North Carolina"] # The states used in the SQL query below

countiesFC = # add the path to your counties feature class
GAcounties = '"' + stateName + '" = ' + "'" + states[0] + "'"
NCcounties = '"' + stateName + '" = ' + "'" + states[1] + "'"

# Make a feature layer for counties in GA, and in NC
arcpy.MakeFeatureLayer_management(countiesFC, "GA", GAcounties)
arcpy.MakeFeatureLayer_management(countiesFC, "NC", NCcounties)

# Create a search cursor for the Georgia counties feature class
GAcursor = arcpy.SearchCursor("GA")

# Loop through each county in GA, select the NC counties that it shares a line segment with
for county in GAcursor:
    arcpy.SelectLayerByLocation_management("NC", "SHARE_A_LINE_SEGMENT_WITH", county)

    # Do stuff like arcpy.Intersect_analysis(), or arcpy.Copy_management()

Let ArcGIS do all the work. 10.1 has a new tool called "Polygon Neighbors", under Analysis Tools, Proximity, that basically builds an adjacency table for you. You can review the resulting Table, deleting the entries where "Src" and "NBR" are from the same State.

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.