Skip to content

Instantly share code, notes, and snippets.

@ghisprince
Last active December 7, 2015 15:01
Show Gist options
  • Save ghisprince/9262228 to your computer and use it in GitHub Desktop.
Save ghisprince/9262228 to your computer and use it in GitHub Desktop.
def connect_parts(fc):
"""
Takes each part of a line feature. If made of more than one path
(aka segment, aka part) connects them into a single path.
Vertices are unchanged.
Code authored on ArcGIS ver 10.2.2
"""
import json
with arcpy.da.UpdateCursor(fc, "Shape@JSON") as uc:
for row in uc:
j = json.loads(row[0])
paths = j['paths']
if len(paths) > 1:
j['paths'] = [list(itertools.chain(*paths))]
uc.updateRow([json.dumps(j),])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment