Created
June 10, 2013 20:18
-
-
Save oevans/5751907 to your computer and use it in GitHub Desktop.
Step 4 - Create features.
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
import arcpy, datetime, os, simplejson as json | |
cwd = os.getcwd() | |
### Load JSON File ### | |
with open('damageassessmentservice.json') as data_file: | |
data = json.load(data_file) | |
### Create Features ### | |
rows = arcpy.InsertCursor(cwd + '/data.gdb/Damage_Assessment') | |
for cfX in data['layers'][0]['features']: | |
pnt = arcpy.Point() | |
pnt.X = cfX['geometry']['x'] | |
pnt.Y = cfX['geometry']['y'] | |
row = rows.newRow() | |
row.shape = pnt | |
row.setValue('ASSET', cfX['attributes']['ASSET']) | |
row.setValue('CONDITION', cfX['attributes']['CONDITION']) | |
row.setValue('NOTES', cfX['attributes']['NOTES']) | |
row.setValue('CreationDate', datetime.datetime.utcfromtimestamp(cfX['attributes']['CreationDate']/1000)) | |
row.setValue('Creator', cfX['attributes']['Creator']) | |
row.setValue('EditDate', datetime.datetime.utcfromtimestamp(cfX['attributes']['EditDate']/1000)) | |
row.setValue('Editor', cfX['attributes']['Editor']) | |
row.setValue('GlobalID_Str', cfX['attributes']['GlobalID']) | |
rows.insertRow(row) | |
del row | |
del rows |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment