Skip to content

Instantly share code, notes, and snippets.

View ghisprince's full-sized avatar

Ghislain Prince ghisprince

View GitHub Profile
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:
@ghisprince
ghisprince / export_fc_to_csv.py
Last active December 7, 2015 15:01
Export each vertex in a line or poly fc to a csv with OID
def export_fc_to_csv(fc, out_csv):
"""
Export each vertex in a line or poly fc to a csv with OID
user requested at http://arcpy.wordpress.com/about/#comment-348
example
import geom_snippets
geom_snippets.export_fc_to_csv(r"c:\proj\fc1.shp", r"c:\proj\fc1.csv")
@ghisprince
ghisprince / pprint_fields.py
Created August 7, 2014 18:25
pretty print table's fields
import arcpy
def pprint_fields(table):
""" pretty print table's fields and their properties """
def _print(l):
print("".join(["{:>12}".format(i) for i in l]))
atts = ['name', 'aliasName', 'type', 'baseName', 'domain',
'editable', 'isNullable', 'length', 'precision',
'required', 'scale',]
_print(atts)
for f in arcpy.ListFields(table):
@ghisprince
ghisprince / strava_streams_api.py
Created August 14, 2014 04:03
how to return streams
### CURRENT
# Result is a enum of streams in any order. To get a particular stream you loop through them,
# and ask for it's type. A particular requested stream is not returned if it's not
# on the activity (need to code defensively).
streams = client.get_activity_streams(123, types=types, resolution='medium')
heartrate_stream = None
for s in streams: