-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcurve_check.py
100 lines (83 loc) · 3.44 KB
/
curve_check.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# -*- coding: utf-8 -*-
"""
Created on Mon Dec 20 15:11:45 2021
@author: eneemann
Script to identify and list curvepart features
"""
import arcpy
import os
import time
# Start timer and print start time in UTC
start_time = time.time()
readable_start = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
print("The script start time is {}".format(readable_start))
######################
# Set up variables #
######################
today = time.strftime("%Y%m%d")
#db = r"L:\agrc\data\ng911\Submitted_to_911DM\UtahNG911GIS_20220106.gdb"
#db = r"\\itwfpcap2\AGRC\agrc\data\ng911\SpatialStation_live_data\UtahNG911GIS.gdb"
# db = r'C:\Users\eneemann\Desktop\Neemann\NG911\NG911_project\C:\Users\eneemann\Desktop\Neemann\NG911\NG911_project\NG911_project.gdb'
#db = r"C:\Users\eneemann\Desktop\Neemann\NG911\NG911_project\NG911_data_updates.gdb"
#db = r"C:\Users\eneemann\AppData\Roaming\ESRI\ArcGISPro\Favorites\internal@[email protected]"
db = r'C:\Users\eneemann\Desktop\Neemann\NG911\NG911_PSAP_Boundaries.gdb'
#FC = os.path.join(db, r'Fire')
FC = os.path.join(db, r'PSAP_TEST_euclid_ring')
# FC = os.path.join(db, r'EMS_Boundaries\NG911_Fire_bounds_20220407')
# FC = r'C:\Users\eneemann\Desktop\Neemann\NG911\NG911_project\0 NG911_Fire_Shapefile_20220705\NG911_Fire_bounds_20220705.shp'
print(f"Working on: {FC}")
arcpy.env.workspace = db
def curve_check(fc):
curve_count = 0
curve_oids = []
print('Checking for curves using the SHAPE@JSON token ...')
fields = ['OID@', 'SHAPE@JSON']
with arcpy.da.SearchCursor(fc, fields) as search_cursor:
print("Looping through rows in FC to check for true curve features ...")
for row in search_cursor:
j = row[1]
oid = row[0]
if 'curve' in j:
curve_oids.append(oid)
curve_count += 1
print(f'OID {oid} has a curve!')
# print(j["curveRings"][0][0])
# print(j.split("curveRings:"))
# print(j['{"curveRings"}][0][0])
# print(j)
print(j.split(']')[0])
print(f'Total count of curve features: {curve_count}')
if len(curve_oids) > 0:
print('curve OIDs:')
for o in curve_oids:
print(o)
##########################
# Call Functions Below #
##########################
curve_check(FC)
# 2nd version of curve check from StackExchange: https://gis.stackexchange.com/questions/37793/identifying-true-curves-arcs-in-arcmap/179155#179155
# This version doesn't apper to work
# import json
# geometries = arcpy.CopyFeatures_management(FC, arcpy.Geometry())
# for g in geometries:
# j = json.loads(g.JSON)
# if 'curve' in j:
# print("You have true curves!")
# else:
# print("No curves here")
# 3rd version of curve check using geometries and the hasCurves property
print('Checking for curves from geometry hasCurves property ...')
curve_count_g = 0
geometries = arcpy.CopyFeatures_management(FC, arcpy.Geometry())
for g in geometries:
if g.hasCurves:
curve_count_g += 1
print("Feature with a true curve found!")
# else:
# print("No curves here")
print(f'Total count of curve features: {curve_count_g}')
print("Script shutting down ...")
# Stop timer and print end time in UTC
readable_end = time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime())
print("The script end time is {}".format(readable_end))
print("Time elapsed: {:.2f}s".format(time.time() - start_time))