1

I am working in ArcMap. I have a map of districts in South Carolina, and I'm trying to find the boundary length that every district has with every other district, and the boundary of South Carolina itself. I understand that the GeoProcessing tool Polygon Neighbors can find the boundary lengths between polygons, but I also need the length that a district has with the edge of the state.

I am trying to verify that whatever values I get here correspond accurately with the perimeter of each district, so I don't simply want to use the perimeter tool and subtract off the sum of other neighbor lengths.

I have considered creating a buffer polygon around the state to act as an "outside" district, but I'm not sure how to do that.

  • Add two fields to your polygon neighbor, left_dist and right_dist, join to your polygons using left_FID, calculate your left_dist as the name of the joined polygon, remove join and do likewise for right. Now you have the district on both sides, select where left_dist = your focus district or right_dist = your other focus district and use summary statistics to sum the length. – Michael Stimson Feb 25 at 3:43
  • Thanks for the quick feedback Michael. I'm not quite sure I understand your idea. Is it to join the polygons and find the perimeter on the outside of the entire state? Will that be left_dist? Should I do this analysis after generating the polygon neighbors table? – BSplitter Feb 25 at 3:57
  • Yes, the polygon neighbors tool creates a line feature class with the FID of the left and right polygon.. the tricky part is that a line can go in either direction (A on left, B on right or B on left, A on right). The lines have, or can have, length which is your perimeter. It would be best to do this in a geodatabase: shape length is automatically calculated and all FIDs are static. When you have a table with left name and right name you may need to do some swapping (alphabetically perhaps) then run summary statistics to find the sum of lengths with case of left/right name. – Michael Stimson Feb 25 at 4:02
  • Polygon neighbors tool creates a table, no polylines. – FelixIP Feb 25 at 7:31
2

The trick here is counting number of neighbors that share polygon edges. Workflow for that using spatial join one to many:

arcpy.Integrate_management(in_features="COUNTIES #", cluster_tolerance="0.01 Meters")
arcpy.FeatureToLine_management(in_features="COUNTIES", out_feature_class="C:/SCRATCH/to_dissolve.shp", cluster_tolerance="", attributes="NO_ATTRIBUTES")
arcpy.Dissolve_management(in_features="to_dissolve", out_feature_class="C:/SCRATCH/edges.shp", dissolve_field="", statistics_fields="", multi_part="SINGLE_PART", unsplit_lines="DISSOLVE_LINES")
arcpy.SpatialJoin_analysis(target_features="edges", join_features="COUNTIES", out_feature_class="C:/SCRATCH/SCRATCH.gdb/SJ_12M", join_operation="JOIN_ONE_TO_MANY", join_type="KEEP_ALL", field_mapping="", match_option="SHARE_A_LINE_SEGMENT_WITH", search_radius="", distance_field_name="")

Add field NEIGHBOURS, compute count of polygons per TARGET_FID in spatial join output, transfer it back to the same table:

enter image description here

Visually inspect spatial joins and make sure outer (1 neighbour) and inside edges (2 neighbours) located where expected (if this is not the case, fix topology of polygons):

enter image description here

  • Select outer (1 neighbour) spatial joins (edges) and transfer their lengths to relevant field in counties table using JOIN_FID for join.
  • Select inside (2 neighbour) spatial joins, summarise by JOIN_FID and transfer their total length to relevant field in counties table using JOIN_FID for join:

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.