Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a dataset of zipcodes.

I want to add a new field "NEIGHBORS" that includes bordering polygons in a comma delimited manner such as attached image:

bordering polygons added to field

share|improve this question

You could use the ArcGIS Polygon Neighbors Tool, in the Analysis, Proximity Toolset to determine which are the bordering polygons.

share|improve this answer

As answered by @klewis the Polygon Neighbors tool is the key for writing what polygons are neighbors of each other into a Table.

However, I suggest you wrap that tool inside Python code like the test code below to do the additional steps of adding the field to hold your comma delimited list of neighbors, and some cursor work to read the one-to-many relationship between polygons and their neighbors and flatten them into that field. This test starts by creating a 3x3 test data set.

To see the result open ArcMap and drag in and then label the testFishnet feature class on the NEIGHBORS field.

import arcpy

if arcpy.Exists(r"C:\Support\user4015\test.gdb"):


arcpy.CreateFishnet_management("C:/Support/user4015/test.gdb/testFishnet","0 0","0 1","1","1","3","3",


with arcpy.da.UpdateCursor("C:/Support/user4015/test.gdb/testFishnet",["OID","NEIGHBORS"]) as uCursor:
    for uRow in uCursor:
        arcpy.SelectLayerByAttribute_management("testNeighbors_View","NEW_SELECTION","src_OID = " + str(uRow[0]))
        with arcpy.da.SearchCursor("testNeighbors_View","nbr_OID") as sCursor:
            neighbors = ""
            for sRow in sCursor:
                neighbors = neighbors + "," + str(sRow[0])      
        uRow[1] = neighbors.strip(",")
share|improve this answer

Your Answer


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.