Last active
December 7, 2015 15:01
-
-
Save ghisprince/9262228 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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