-
Notifications
You must be signed in to change notification settings - Fork 0
/
CountyAddressPointETL.py
5083 lines (4022 loc) · 235 KB
/
CountyAddressPointETL.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
from dataclasses import _MISSING_TYPE
import arcpy
import datetime, time
from pathlib import Path
import sys
import re
import os
import agrc
import CreateApartmentDuplicates
from arcpy import env
from agrc import parse_address
from CreateApartmentDuplicates import addBaseAddress
from DeletePoints import deleteDuplicatePts
from DeletePoints import delete_by_query
from CreateErrorPts import createErrorPts
from ReturnDuplicateAddresses import returnDuplicateAddresses
from ReturnDuplicateAddresses import updateErrorPts
from compareSGIDpts import findMissingPts
from UpdatePointAttributes import addPolyAttributes
from UpdatePointAttributes import updateAddPtID
from UpdatePointAttributes import updateField
from PointTypeUpdater import UpdatePropertyTypeLIR, ptTypeUpdates_SaltLake
from PointTypeUpdater import addPolyAttributesLIR
from sweeper.address_parser import Address
global sgid, agrcAddFLDS, errorList
sgid = str(Path(__file__).resolve().parents[3].joinpath('sde', 'SGID_internal', 'SGID_agrc.sde'))
today = str(datetime.datetime.today().strftime("%m/%d/%Y"))
agrcAddFLDS = ['AddSystem', 'UTAddPtID', 'FullAdd', 'AddNum', 'AddNumSuffix', 'PrefixDir', 'StreetName', 'StreetType', \
'SuffixDir', 'LandmarkName', 'Building', 'UnitType', 'UnitID', 'City', 'ZipCode', 'CountyID', 'State', \
'PtLocation', 'PtType', 'Structure', 'ParcelID', 'AddSource', 'LoadDate', 'Status', 'Editor', \
'ModifyDate', 'StreetAlias', 'Notes', 'USNG', 'SHAPE@']
dirs = {'N': ['N', 'NORTH', 'NO'], 'S': ['S', 'SOUTH', 'SO'], 'E': ['E', 'EAST', 'EA'], 'W': ['W', 'WEST', 'WE']}
dirs2 = {'N':'NORTH', 'S':'SOUTH', 'E':'EAST', 'W':'WEST'}
longDirs = ['NORTH', 'SOUTH', 'EAST', 'WEST']
sTypeDir = {'ALY':'ALLEY', 'AVE':'AVENUE', 'BAY':'BAY', 'BND':'BEND', 'BLVD':'BOULEVARD', 'CYN':'CANYON', \
'CTR':'CENTER', 'CIR':['CR', 'CIRCLE'], 'COR':'CORNER', 'CT':'COURT', 'CV':'COVE', 'CRK':'CREEK', \
'CRES':'CRESCENT', 'XING':'CROSSING', 'DR':'DRIVE', 'EST':'ESTATE', 'ESTS':'ESTATES', \
'EXPY':'EXPRESSWAY', 'FLT':'FLAT', 'FRK':'FORK', 'FWY':'FREEWAY', 'GLN':'GLEN', 'GRV':'GROVE', \
'HTS':'HEIGHTS','HWY':'HIGHWAY', 'HL':'HILL', 'HOLW':'HOLLOW', 'JCT':'JUNCTION', 'LN':'LANE', \
'LNDG':'LANDING', 'LOOP':'LOOP', 'MNR':'MANOR','MDW':'MEADOW', 'MDWS':'MEADOWS', 'PARK':'PARK', 'PKWY':'PARKWAY', \
'PASS':'PASS', 'PL':'PLACE', 'PLZ':'PLAZA', 'PT':['POINT', 'POINTE'], 'RAMP':'RAMP', 'RNCH':'RANCH', 'RDG':'RIDGE', \
'RD':'ROAD', 'RST':'REST', 'RTE':'ROUTE', 'ROW':'ROW', 'RUN':'RUN', 'SQ':'SQUARE', 'ST':'STREET', \
'TER':'TERRACE', 'TRCE':'TRACE', 'TRL':'TRAIL', 'VW':'VIEW', 'VLG':'VILLAGE', 'WAY':['WY','WAY']}
sTypeList = ['ALY', 'AVE', 'BAY', 'BND', 'BLVD', 'CYN', 'CTR', 'CIR', 'COR', 'CT', 'CV', 'CRK', 'CRES', 'XING', \
'DR', 'EST', 'ESTS', 'EXPY', 'FLT', 'FRK', 'FWY', 'GLN', 'GRV', 'HTS','HWY', 'HL', 'HOLW', 'JCT', \
'LN', 'LNDG', 'LOOP', 'MNR','MDW', 'MDWS', 'PARK', 'PKWY', 'PASS', 'PL', 'PLZ', 'PT', 'RAMP', 'RNCH', \
'RDG', 'RD', 'RTE', 'ROW', 'RUN', 'SQ', 'ST', 'TER', 'TRCE', 'TRL', 'VW', 'VLG', 'WAY']
addNumSufList = ['1/8', '1/4', '1/3', '1/2', '2/3', '3/4', 'A', 'B', 'C', 'D', 'E', 'F']
unitTypeDir = {'APT':'APARTMENT', 'BSMT':'BASEMENT', 'BLDG':'BUILDING', 'DEPT':'DEPARTMENT', 'FL':['FLOOR', 'FLR'],\
'FRNT':'FRONT', 'HNGR':'HANGAR', 'KEY':'KEY', 'LBBY':'LOBBY', 'LOT':'LOT', 'LOWR':'LOWER', 'OFC':'OFFICE', \
'PH':'PENTHOUSE', 'PIER':'PIER', 'REAR':'REAR', 'RM':'ROOM', 'SIDE':'SIDE', 'SLIP':'SLIP', \
'SPC':['SP', 'SPACE'], 'STOP':'STOP', 'STE':'SUITE', 'TRLR':['TRAILER', 'TRL'], 'UNIT':'UNIT', 'UPPR':'UPPER'}
unitTypeList = ['APT', 'APARTMENT', 'BSMT', 'BASEMENT', 'BLDG', 'BUILDING', 'DEPT', 'DEPARTMENT', 'FL', 'FLOOR', 'FLR',
'FRNT', 'FRONT', 'HNGR', 'HANGAR', 'KEY', 'LBBY', 'LOBBY', 'LOT', 'LOWR', 'LOWER', 'OFC', 'OFFICE',
'PH', 'PENTHOUSE', 'PIER', 'REAR', 'RM', 'ROOM', 'SIDE', 'SLIP', 'SPC', 'SP', 'SPACE', 'STOP', 'STE',
'SUITE', 'TRLR', 'TRAILER', 'TRL', 'UNIT', 'UPPR']
noUnitIds = ['BSMT', 'FRNT', 'LBBY', 'LOWR', 'OFC', 'PH', 'REAR', 'SIDE', 'UPPR']
errorList = [None, False, 'None', '<Null>', 'NULL', '', ' ', '#', '####', '--', '.', '~', '-?', '--?', '?', '09-0000-01',
'0', '00', '000', '??0', '0 STREET', '*', '(Future )', '(FUTURE )', 'Unknown', 'UNKNOWN', '09-0000-01', ',ILLER', '+', 0]
leadingSpaceTypes = []
for t in sTypeDir:
leadingSpaceTypes.append(f' {t}')
leadingSpaceTypes.append(' STREET')
class clean_street_name:
def __init__(self, words):
directions = ['N', 'S', 'E', 'W', 'NORTH', 'SOUTH', 'EAST', 'WEST']
self.name = ' '.join(words.split()[:-1])
if words.split()[-1] in directions:
self.direction = returnKey(words[-1], dirs)
self.type = ''
else:
self.type = returnKey(words.split()[-1], sTypeDir)
self.direction = ''
def fix_road_name(road_name):
return clean_street_name(road_name)
def checkWord(word, d):
for key, value in d.items():
if word in value:
return key
# if nothing is found
return ''
def returnKey(word, d):
if word == None:
word = ''
word = word.upper()
for key, value in d.items():
if word == '':
return ''
if word == key:
return key
if type(value) is str:
if word == value:
return key
else:
for v in value:
if word == v:
return key
return ''
def returnKey_noCase(word, d):
if word == None:
word = ''
for key, value in d.items():
if word == '':
return ''
if word == key:
return key
if type(value) is str:
if word == value:
return key
else:
for v in value:
if word == v:
return key
return ''
def removeBadValues(word, badVals):
if word in badVals:
word = ''
if word == None:
word = ''
return word.upper().strip()
def addNone(word, badVals):
if word in badVals:
word = None
return word
def removeNone(word):
if word == None:
word = ''
return word
def formatValues(word, inValues):
removeBadValues(word, errorList)
if word != None:
if word.upper().strip() in inValues:
return word.upper().strip()
return ''
return ''
def formatUnitID(unitID):
if unitID != None:
unitID = unitID.strip()
if unitID.startswith('#') is True:
if unitID[1] != ' ':
return f'{unitID[0]} {unitID}'.strip('#').upper()
return unitID
elif unitID.startswith('#') is False:
if unitID not in errorList:
return '# ' + unitID.upper()
return unitID
return ''
def formatAddressNumber(addNum):
removeBadValues(addNum, errorList)
addNum.strip()
if addNum.startswith('0'):
addNum = addNum.lstrip('0')
return addNum
def removeDuplicateWords(words):
slist = words.split()
return ' '.join(sorted(set(slist), key=slist.index))
def truncateOldCountyPts(inPts):
pointCount = int(arcpy.GetCount_management(inPts).getOutput(0))
if pointCount > 0:
arcpy.TruncateTable_management(inPts)
print (f'Deleted {pointCount} points in {inPts}')
else:
print ('No points to delete')
def splitVals(word, list):
if word == None:
return ('', '')
srch = re.compile('|'.join(list))
match = re.match(srch, word)
if match != None:
v1 = match.group()
v2 = word.replace(v1, '').strip()
sVals = (v1, v2)
return sVals
else:
return ('' , word)
def returnStart(str, startList):
for s in startList:
if str.startswith(s):
return s
def returnEnd(str, endList):
for s in endList:
if str.endswith(s):
return s
def createRoadSet(countyNumber):
sgidRds = str(Path(__file__).resolve().parents[3].joinpath('sde', 'SGID_internal', 'SGID_agrc.sde', 'SGID.TRANSPORTATION.Roads'))
rdFlds = ['COUNTY_L', 'NAME', 'POSTTYPE']
rdList = []
with arcpy.da.SearchCursor(sgidRds, rdFlds) as sCursorRds:
for rowRd in sCursorRds:
if rowRd[0] == countyNumber and rowRd[1] != '':
rdList.append(rowRd[1].upper())
RoadNameSet = set(rdList)
return RoadNameSet
def createRoadSet_County(road_fc, road_flds, county_name):
# road_flds needs to be ordered [RoadName, County]
# county_name needs to be the same as in the county roads data
road_list = []
with arcpy.da.SearchCursor(road_fc, road_flds) as scursor:
for row in scursor:
if row[1] in [county_name, None, ''] and row[0] != '' and row[0] != None:
if row[0][0].isdigit() and row[0].strip().endswith((' NORTH', ' SOUTH', ' EAST', ' WEST')):
road_list.append(row[0].split()[0])
else:
road_list.append(row[0].upper())
RoadNameSet_County = set(road_list)
return RoadNameSet_County
def archive_last_month(archive_pts):
with arcpy.da.SearchCursor(archive_pts, 'LoadDate') as icursor:
load_date = str(next(icursor)[0]).split()[0].replace('-', '')
out_archive = f'{archive_pts}{load_date}'
arcpy.management.CopyFeatures(archive_pts, out_archive)
def agol_to_fgdb(county, fs_url):
county_fgdb = f'..\{county}\{county}County.gdb'
with arcpy.EnvManager(workspace=county_fgdb):
arcpy.env.overwriteOutput = True
fc = f'{county}_agol_pts'
arcpy.conversion.ExportFeatures(fs_url, fc)
print(f'Exported {county} AGOL points to {county_fgdb}')
def beaverCounty():
beaverCoAddPts = r'..\Beaver\BeaverCounty.gdb\Address_pts'
agrcAddPts_beaverCo = r'..\Beaver\Beaver.gdb\AddressPoints_Beaver'
cntyFldr = r'..\Beaver'
beaverCoAddFLDS = ['Address', 'Prefix', 'St_Name', 'Dir_Type', 'Unit_Num', 'Grid', 'SHAPE@', 'OBJECTID', 'Parcel_ID']
fix_dict = {'NORTHCREEK':'NORTH CREEK', 'ELK MEADOW':'ELK MEADOWS', 'NORTH CREE':'NORTH CREEK'}
remove_type = ['MAIN ST', 'PINE LN', 'MT BELKNAP PLACE']
rdSet = createRoadSet('49001')
checkRequiredFields(beaverCoAddPts, beaverCoAddFLDS)
archive_last_month(agrcAddPts_beaverCo)
truncateOldCountyPts(agrcAddPts_beaverCo)
errorPtsDict = {}
with arcpy.da.SearchCursor(beaverCoAddPts, beaverCoAddFLDS) as sCursor, \
arcpy.da.InsertCursor(agrcAddPts_beaverCo, agrcAddFLDS) as iCursor:
for row in sCursor:
if row[0] not in errorList and row[2] not in errorList:
addNum = row[0]
preDir = formatValues(row[1], dirs)
sufDir = formatValues(row[3].upper(), dirs)
sType = returnKey(row[3].upper(), sTypeDir)
sName = row[2].upper().replace('HIGHWAY', 'HWY')
if sName.endswith((' N', ' S', ' E', ' W')):
sufDir = sName.split()[1]
sType = ''
sName = sName.split()[0]
if sName[1].isdigit() and sName.endswith(tuple([' ' + dir for dir in longDirs])):
sufDir = sName.split()[1][0]
sName = sName.split()[0]
if sName.endswith(' ROAD'):
sType = 'RD'
sName = sName[:-5].strip()
if sName == 'NORTH CREEK' and sType == '':
sType = 'RD'
if 'HWY' not in sName and sName not in rdSet:
addressErrors = errorPtsDict.setdefault(f'OID {row[7]} | {row[2]}', [])
addressErrors.extend(['street name not in roads', row[6]])
if sName in fix_dict:
sName = fix_dict[sName]
if sName in remove_type:
sType = returnKey(sName.split()[-1], sTypeDir)
sName = ' '.join(sName.split()[:-1])
if row[3].upper() == 'TR':
sType = 'TRL'
unitID = removeBadValues(row[4], errorList)
if unitID != '':
unitID_hash = '# ' + unitID
else:
unitID_hash = ''
addSys = row[5].upper()
parcel_id = removeNone(row[8])
shp = row[6]
fullAdd = f'{addNum} {preDir} {sName} {sufDir} {sType} {unitID_hash}'
fullAdd = ' '.join(fullAdd.split())
utPtID = f'{addSys} | {fullAdd}'
if sufDir == '' and sType == '' and 'HWY' not in sName:
addressErrors = errorPtsDict.setdefault(fullAdd, [])
addressErrors.extend(['missing street type', row[6]])
if preDir != '' and preDir == sufDir:
addressErrors = errorPtsDict.setdefault(fullAdd, [])
addressErrors.extend(['predir = sufdir', row[6]])
iCursor.insertRow((addSys, utPtID, fullAdd, addNum, '', preDir, sName, sType, sufDir, '', '',\
'', unitID, '', '', '49001', 'UT', '', '', '', parcel_id, 'BEAVER COUNTY', today,\
'COMPLETE', '', None, '', '', '', shp))
errorFlds = createErrorPts(errorPtsDict, cntyFldr, 'Beaver_ErrorPts.shp', beaverCoAddFLDS[1], beaverCoAddPts)
del iCursor
intersectPolyDict = {'City':['SGID.BOUNDARIES.Municipalities', 'SHORTDESC', ''],
'ZipCode':['SGID.BOUNDARIES.ZipCodes', 'ZIP5', ''],
'USNG': ['SGID.INDICES.NationalGrid', 'USNG', '']}
addPolyAttributes(sgid, agrcAddPts_beaverCo, intersectPolyDict)
updateAddPtID(agrcAddPts_beaverCo)
addBaseAddress(agrcAddPts_beaverCo)
deleteDuplicatePts(agrcAddPts_beaverCo, ['UTAddPtID', 'SHAPE@WKT', 'OBJECTID'])
dupePts = returnDuplicateAddresses(agrcAddPts_beaverCo, ['UTAddPtID', 'SHAPE@'])
updateErrorPts(os.path.join(cntyFldr, 'Beaver_ErrorPts.shp'), errorFlds, dupePts)
def boxElderCounty():
boxelderCoAddPts = r'..\BoxElder\BoxElderCounty.gdb\BECO_Address_Points'
agrcAddPts_boxelderCo = r'..\BoxElder\BoxElder.gdb\AddressPoints_BoxElder'
cntyFldr = r'..\BoxElder'
boxelderCoAddFLDS = ['FullAddr', 'HouseNum', 'PreDir', 'StreetName', 'StreetType', 'SufDir', 'UnitNumber', 'UnitType', 'City', \
'ZipCode', 'Parcel_ID', 'Structure', 'COMPLEX_NA', 'Use_Classi', 'last_edi_1', 'SHAPE@', 'STREET_ALI']
# useDict = {'AGR':'Agricultural', 'COM':'Commercial', 'EDU':'Education', 'GOV':'Government', 'MED':'Other', 'RES':'Residential',\
# 'MHU':'Residential', 'MOB':'Residential', 'REL':'Other', 'VAC':'Vacant'}
ptTypeDict = {'Agricultural':'AGR', 'Commercial':['COM'], 'Residential':['Residential', 'RES', 'MOB', 'MHU'],
'Other':['EDU', 'GOV', 'Med', 'OTH', 'REL'], 'Vacant':'VAC', 'Unknown':''}
excludeUnit = ['UPSTAIRS', 'UP', 'MANAGER', 'DOWNSTAIRS', 'DOWN', 'CLUB', 'BASEMENT']
#sTypeTuple = tuple(sTypeList)
checkRequiredFields(boxelderCoAddPts, boxelderCoAddFLDS)
#archive_last_month(agrcAddPts_boxelderCo)
truncateOldCountyPts(agrcAddPts_boxelderCo)
errorPtsDict = {}
iCursor = arcpy.da.InsertCursor(agrcAddPts_boxelderCo, agrcAddFLDS)
with arcpy.da.SearchCursor(boxelderCoAddPts, boxelderCoAddFLDS) as sCursor:
for row in sCursor:
addNum = removeBadValues(row[1], errorList)
if addNum != '' and row[3] not in errorList:
addSys = ''
if ' ' in addNum:
addNumSuf = addNum.split()[1]
addNum = addNum.split()[0]
else:
addNumSuf = ''
preDir = removeBadValues(row[2], errorList)
sName = row[3].strip()
if row[4] in errorList:
sType = ''
else:
sType = returnKey(row[4].strip(), sTypeDir)
if sName.endswith((' RD', ' DR', ' ST', ' AVE')):
sType = sName[-2:]
sName = sName[:-2].strip()
if sName.endswith((' DRIVE', ' LANE', ' ROAD')):
sType = returnKey(sName.split()[-1], sTypeDir)
sName = sName.rsplit(' ', 1)[0]
sufDir = ''
print(sName)
if sName[0].isdigit() == True and sName.endswith((' N', ' S', ' E', ' W')):
sufDir = sName[-1]
sName = sName.replace(sName[-2:], '')
if sName.startswith(('HIGHWAY ')):
sName = sName.replace('HIGHWAY', 'HWY')
sufDir = removeBadValues(row[5], errorList)
if sType != '':
sufDir = ''
if sName == '1200' and row[15] == 'ROCKET ROAD':
sName = 'ROCKET'
sType = 'RD'
sufDir = ''
if sName[0].isdigit() == False:
sufDir = ''
if sName == 'SADDLEBACK':
sType = 'RD'
sName = sName.upper()
if row[6] not in errorList:
unitNum = row[6].strip('#').strip().upper()
else:
unitNum = ''
unitType = returnKey(row[7].upper(), unitTypeDir)
city = ''
zip = row[9]
parcelID = row[10]
structure = removeBadValues(row[11], errorList)
building = removeBadValues(row[12], errorList)
ptType = returnKey_noCase(removeNone(row[13]), ptTypeDict)
addSource = 'BOX ELDER COUNTY'
modDate = row[14]
loadDate = today
shp = row[15]
if unitType == '' and unitNum != '':
fullAdd = f'{addNum} {addNumSuf} {preDir} {sName} {sufDir} {sType} # {unitNum}'
else:
fullAdd = f'{addNum} {addNumSuf} {preDir} {sName} {sufDir} {sType} {unitType} {unitNum}'
fullAdd = ' '.join(fullAdd.split())
#-----------Create Error Points-----------
if preDir == sufDir and sType == '':
addressErrors = errorPtsDict.setdefault(fullAdd, [])
addressErrors.extend(['predir = sufdir', row[15]])
if row[3] != None and row[0] != None:
if row[3] not in row[0]:
addressErrors = errorPtsDict.setdefault(f'{row[3]} | {row[0]}', [])
addressErrors.extend(['StreetName not in FullAddr', row[15]])
iCursor.insertRow((addSys, '', fullAdd, addNum, addNumSuf, preDir, sName, sType, sufDir, '', building, unitType,\
unitNum, city, zip, '49003', 'UT', '', ptType, structure, parcelID, addSource, loadDate, \
'COMPLETE', '', modDate, '', '', '', shp))
errorFlds = createErrorPts(errorPtsDict, cntyFldr, 'BoxElder_ErrorPts.shp', 'Address', boxelderCoAddPts)
del iCursor
del sCursor
inputDict = {'AddSystem':['SGID.LOCATION.AddressSystemQuadrants', 'GRID_NAME', ''],
'USNG':['SGID.INDICES.NationalGrid', 'USNG', ''],
'City': ['SGID.BOUNDARIES.Municipalities', 'SHORTDESC', ''],}
addPolyAttributes(sgid, agrcAddPts_boxelderCo, inputDict)
updateAddPtID(agrcAddPts_boxelderCo)
addBaseAddress(agrcAddPts_boxelderCo)
deleteDuplicatePts(agrcAddPts_boxelderCo, ['UTAddPtID', 'SHAPE@WKT', 'OBJECTID'])
dupePts = returnDuplicateAddresses(agrcAddPts_boxelderCo, ['UTAddPtID', 'SHAPE@'])
updateErrorPts(os.path.join(cntyFldr, 'BoxElder_ErrorPts.shp'), errorFlds, dupePts)
def cacheCounty():
cacheCoAddPts = r'..\Cache\CacheCounty.gdb\CacheAddressPoints'
agrcAddPts_cacheCo = r'..\Cache\Cache.gdb\AddressPoints_Cache'
cntyFldr = r'..\Cache'
cacheCoAddFLDS = ['addsystem', 'fulladd', 'addnum', 'addnumsuffix', 'prefixdir', 'streetname', 'streettype', 'suffixdir',
'landmarkname', 'building', 'unittype', 'unitid', 'ptlocation', 'pttype', 'structure', 'parcelid',
'addsource', 'last_edited_date', 'SHAPE@', 'OBJECTID']
flrDict = {'BSMT':['FLR BSMT','FLR BMST', 'FLR BSMT EAST', 'FLR BSMT RIGHT', 'FLR BSMT S', 'FLR DWNSTRS'],
'REAR':['FLR REAR'], 'UPPR':['FLR UPPER', 'FLR UPSTRS', 'FLR UPSTRS; APT 1', 'UPSTRS'],
'FRNT':['FR', 'FRONT'], 'OFC':['OFFICE'], 'RM':['ROOM']}
cacheTypesDict = {'ALY':'ALLEY', 'AVE':'AVENUE', 'BAY':'BAY', 'BND':'BEND', 'BLVD':'BOULEVARD', 'CYN':'CANYON',
'CTR':'CENTER', 'CIR':'CIRCLE', 'COR':'CORNER', 'CT':'COURT', 'CV':'COVE', 'CRK':'CREEK',
'CRES':'CRESCENT', 'XING':'CROSSING', 'DR':'DRIVE', 'EST':'ESTATE', 'ESTS':'ESTATES',
'EXPY':'EXPRESSWAY', 'FLT':'FLAT', 'FRK':'FORK', 'FWY':'FREEWAY', 'GLN':'GLEN', 'GRV':'GROVE',
'HTS':'HEIGHTS','HWY':'HIGHWAY', 'HL':'HILL', 'HOLW':'HOLLOW', 'JCT':'JUNCTION', 'LN':'LANE',
'LNDG':'LANDING', 'LOOP':['LP', 'LOOP'], 'MNR':'MANOR','MDW':'MEADOW', 'MDWS':'MEADOWS', 'PARK':'PARK',
'PKWY':'PARKWAY', 'PASS':'PASS', 'PL':'PLACE', 'PLZ':'PLAZA', 'PT':'POINT', 'RAMP':'RAMP', 'RNCH':'RANCH',
'RDG':'RIDGE', 'RD':'ROAD', 'RTE':'ROUTE', 'ROW':'ROW', 'RUN':'RUN', 'SQ':'SQUARE', 'ST':'STREET',
'TER':'TERRACE', 'TRCE':'TRACE', 'TRL':'TRAIL', 'VW':'VIEW', 'VLG':'VILLAGE', 'WAY':'WAY'}
hwy_dict = {'SR 101':'HWY 101', 'SR 142':'HWY 142', 'SR 165':'HWY 165', 'SR 23':'HWY 23', '23 SR':'HWY 23',
'SR 30':'HWY 30', 'US 89':'HWY 89', 'US 89/91':'HWY 89/91', 'HWY 89-91':'HWY 89/91',
'US 91':'HWY 91'}
ptTypeDict = {'Agricultural':['LAND AGRICULTURE', 'LAND GREENBELT'], 'Commercial':['LAND COMMERCIAL'],
'Residential':['LAND RESIDENTIAL', 'LAND SECONDARY'], 'Vacant':['LAND VACANT']}
checkRequiredFields(cacheCoAddPts, cacheCoAddFLDS)
archive_last_month(agrcAddPts_cacheCo)
truncateOldCountyPts(agrcAddPts_cacheCo)
errorPtsDict = {}
#rdSet = createRoadSet('49005')
iCursor = arcpy.da.InsertCursor(agrcAddPts_cacheCo, agrcAddFLDS)
with arcpy.da.SearchCursor(cacheCoAddPts, cacheCoAddFLDS) as sCursor:
for row in sCursor:
addnum = removeBadValues(row[2], errorList)
sName = removeBadValues(row[5], errorList)
building = ''
if addnum not in errorList and sName not in errorList and row[0] != 'Franklin County':
preDirSrc = removeBadValues(row[4], errorList)
if len(preDirSrc) <= 2:
predir = returnKey(preDirSrc.strip(), dirs)
else:
continue
addnumsuf = removeBadValues(row[3], errorList)
for a in addNumSufList:
if len(addnum) > 2:
if f' {a}' in addnum:
addnumsuf = a
suf_form = int(f'-{len(addnumsuf)}')
addnum = addnum[:suf_form]
print(f'{row[19]} {addnum}')
if '-' in addnum:
if addnum.split('-')[1] == row[9]:
addnumsuf = ''
building = f'BLDG {row[9]}'
addnum = addnum.split('-')[0]
if '.5' in addnum:
addnumsuf = '1/2'
addnum = addnum.split('.')[0]
modTypes = removeNone(row[6])
sType = returnKey(modTypes.strip(), cacheTypesDict)
sufdir = formatValues(row[7], dirs)
if sName in hwy_dict:
sName = hwy_dict[sName]
if sName.isdigit() == False:
sufdir = ''
if sName.isdigit() == True:
sType = ''
if sName == 'LYNNWOOD':
predir = 'E'
if predir == sType and sName != 'BOULEVARD':
continue
landName = removeBadValues(row[8], errorList)
unitType = returnKey(row[10], unitTypeDir)
unitId_src = removeBadValues(row[11], errorList)
unitId_src = re.sub('[()#]', '', unitId_src).strip()
if unitType not in noUnitIds and unitId_src == '':
unitType = ''
if len(unitId_src) < 14:
if ';' in unitId_src:
if unitId_src.split(';')[0].startswith('BLDG'):
building = unitId_src.split(';')[0]
unitType = unitId_src.split()[2]
unitId = unitId_src.split()[3]
elif unitId_src.startswith('BLDG'):
building = unitId_src
unitId = ''
elif unitId_src.startswith('FLR'):
if unitId_src == 'FLR MAIN':
unitType = 'FL'
unitId = 'MAIN'
else:
unitId = returnKey(unitId_src.strip('FLR '), flrDict)
elif len(unitId_src.split()) > 1:
if returnKey(unitId_src.split()[0], flrDict) != '':
unitType = returnKey(unitId_src.split()[0], flrDict)
if unitId_src.split()[-1].isdigit():
unitId = unitId_src.split()[-1]
elif returnKey(unitId_src, flrDict) != '':
unitId = returnKey(unitId_src, flrDict)
if len(unitId_src.split()) > 1:
if unitId_src.split()[-1].isdigit():
unitId = unitId_src.split()[-1]
else:
unitId = unitId_src
else:
unitId = ''
if sName == '200 E MEMORY':
addnum = 200
sName = 'MEMORY'
predir = 'E'
sType = 'LN'
unitId = row[2]
parcelId = removeBadValues(row[15], errorList)
addSrc = removeBadValues(row[16], errorList)
modDate = row[17]
loadDate = today
editor = ''
shp = row[18]
if sName == 'BOULEVARD':
sType = 'ST'
if unitType != '' and unitId == '':
unitType = ''
if unitType == '' and unitId != '' and unitId not in flrDict:
fullAdd = f'{addnum} {addnumsuf} {predir} {sName} {sType} {sufdir} {building} {unitType} # {unitId}'
fullAdd = ' '.join(fullAdd.split())
else:
fullAdd = f'{addnum} {addnumsuf} {predir} {sName} {sType} {sufdir} {building} {unitType} {unitId}'
fullAdd = ' '.join(fullAdd.split())
#--------------Create Error Points--------------
# if sName != '' and sName[0].isdigit() == True and sName[-1].isdigit() == False:
# addressErrors = errorPtsDict.setdefault('{} | {}'.format(row[1],row[5]), [])
# addressErrors.extend(['bad street name', row[18]])
# if 'HWY' not in sName and sName not in rdSet:
# addressErrors = errorPtsDict.setdefault('{} | {}'.format(row[1],row[5]), [])
# addressErrors.extend(['street name not in roads', row[18]])
# if sName not in row[1].strip():
# addressErrors = errorPtsDict.setdefault('{} | {}'.format(row[1], row[5]), [])
# addressErrors.extend(['mixed street names', row[18]])
if predir == sufdir and sType == '':
addressErrors = errorPtsDict.setdefault(f'{row[1]} | {row[4]} | {row[7]}', [])
addressErrors.extend(['predir = sufdir', row[18]])
# if row[6] != 'LP' and removeNone(row[6]).strip() not in cacheTypesDict and row[6] not in errorList:
# addressErrors = errorPtsDict.setdefault('{} | {}'.format(row[1], row[6]), [])
# addressErrors.extend(['bad street type', row[18]])
iCursor.insertRow(('', '', fullAdd, addnum, addnumsuf, predir, sName, sType, sufdir, landName, building, unitType, unitId, '',\
'', '49005', 'UT', '', '', '', parcelId, 'CACHE COUNTY', loadDate, 'COMPLETE', editor, modDate, '', '', '', shp))
errorFlds = createErrorPts(errorPtsDict, cntyFldr, 'Cache_ErrorPts.shp', cacheCoAddFLDS[1], cacheCoAddPts)
del sCursor
del iCursor
remapLIR = {'Agricultural': ['Agricultural', 'Greenbelt', 'LAND AGRICULTURE', 'LAND GREENBELT'],
'Commercial': ['LAND COMMERCIAL', 'Commercial', 'Commercial - Office Space', 'Commercial - Retail'],
'Residential': ['LAND RESIDENTIAL', 'LAND SECONDARY'], 'Vacant': ['LAND VACANT']}
inputDict = {
'AddSystem':['SGID.LOCATION.AddressSystemQuadrants', 'GRID_NAME', ''],
'City':['SGID.BOUNDARIES.Municipalities', 'SHORTDESC', ''],
'ZipCode':['SGID.BOUNDARIES.ZipCodes', 'ZIP5', ''],
'USNG':['SGID.INDICES.NationalGrid', 'USNG', ''],
'PtType': ['SGID.CADASTRE.Parcels_Cache_LIR', 'PROP_CLASS', remapLIR]
}
addPolyAttributes(sgid, agrcAddPts_cacheCo, inputDict)
updateAddPtID(agrcAddPts_cacheCo)
addBaseAddress(agrcAddPts_cacheCo)
deleteDuplicatePts(agrcAddPts_cacheCo, ['UTAddPtID', 'SHAPE@WKT', 'OBJECTID'])
dupePts = returnDuplicateAddresses(agrcAddPts_cacheCo, ['UTAddPtID', 'SHAPE@'])
updateErrorPts(os.path.join(cntyFldr, 'Cache_ErrorPts.shp'), errorFlds, dupePts)
def carbonCounty():
carbon_agol_pts = 'https://maps.carbon.utah.gov/arcgis/rest/services/CountyGeneralMap/Addressing_Ownership/MapServer/0'
carbonCoAddPts = r'..\Carbon\CarbonCounty.gdb\Carbon_agol_pts'
#carbonCoAddPts = r'..\Carbon\CarbonCounty.gdb\AddressPoints'
agrcAddPts_carbonCo = r'..\Carbon\Carbon.gdb\AddressPoints_Carbon'
cntyFldr = r'..\Carbon'
agol_to_fgdb('Carbon', carbon_agol_pts)
# carbonCoAddFLDS = ['NAME', 'BUILD_TYPE', 'WHOLE_ADD', 'INDIC_ADDR', 'PRE_DIR', 'ST_NAME', 'ST_TYPE', 'SUF_DIR', 'UNIT_NUM', \
# 'BLDG_NUM', 'PARCEL_NUM', 'GPS_DATE', 'SHAPE@', 'OBJECTID']
carbonCoAddFLDS = ['LandmaName', 'PtType', 'FullAdd', 'AddNum', 'PrefixDir', 'StreetName', 'StreetType', 'SuffixDir', 'UnitID', \
'Building', 'ParcelID', 'ModifyDate', 'SHAPE@', 'OBJECTID', 'UnitType']
checkRequiredFields(carbonCoAddPts, carbonCoAddFLDS)
archive_last_month(agrcAddPts_carbonCo)
truncateOldCountyPts(agrcAddPts_carbonCo)
rdSet = createRoadSet('49007')
errorPtsDict = {}
ptTypeDict = {
'Other' : ['AGRICULTURAL', 'GOVERMENT', 'EDUCATIONAL', 'FIRE HYDRANT', 'MISSING', 'OTHER', 'OUTBUILDING', 'OUT BUILDING', 'PUBLIC',
'PUBLIC WATER TANK', 'RELIGIOUS', 'STREET SIGN', 'TRAIN', 'WATER TANK'],
'Residential' : ['RESIDENTIAL', 'RESIDEENTIAL', 'RESIDENTIAL/COMMERCI'],
'Commercial' : ['COMMERCIAL', 'GARAGE', 'HELPER GUN CLUB'],
'Industrial': ['UTILITY'],
'Unknown':''
}
units = {'APT' : ['APT.', 'APARTMENT'], 'HNGR':'HNGR', 'STE' : ['STE.', 'SUITE'], 'TRLR':['TRAILER'],
'UNIT':'UNIT', 'UPPER':['UPPER', 'UPPR']}
sNameSuffs = [' N', ' S', ' E', ' W']
stripTypes = [' AVE', ' DR', ' LN', ' RD', ' ST', ' WAY']
fix_types = ['WOOD HILL ROAD', 'WESTWOOD BLVD', 'SPRING GLEN ROAD', 'SPRING CANYON ROAD', 'SHELBY LANE', 'AIRPORT ROAD',
'RICHELMAN LANE', 'NORTH COAL CREEK ROAD', 'CONSUMERS ROAD', 'DRY VALLEY ROAD', 'FORD RIDGE ROAD']
iCursor = arcpy.da.InsertCursor(agrcAddPts_carbonCo, agrcAddFLDS)
unitID = ''
with arcpy.da.SearchCursor(carbonCoAddPts, carbonCoAddFLDS) as sCursor_carbon:
for row in sCursor_carbon:
#------- Errror Pts --------
if row[4] not in dirs and row[4] not in longDirs and row[4] not in errorList:
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[4]}', [])
addressErrors.extend(['bad pre dir', row[12]])
if row[5].endswith((' N', ' S', ' E', ' W')):
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[5]}', [])
addressErrors.extend(['suf dir in street name', row[12]])
if row[5].isdigit() and row[4] == row[7] and row[4] not in errorList:
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[4]} | {row[7]}', [])
addressErrors.extend(['pre dir = suf dir', row[12]])
if row[7] not in dirs and row[7] not in longDirs and row[7] not in errorList:
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[7]}', [])
addressErrors.extend(['bad suf dir', row[12]])
if row[5] not in row[2] and row[5] not in errorList and row[2] not in errorList:
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[5]}', [])
addressErrors.extend(['street name not in FullAdd', row[12]])
if row[5].endswith((tuple(leadingSpaceTypes))):
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[5]}', [])
addressErrors.extend(['street type in street name', row[12]])
if row[3].startswith('#') or row[3].endswith(('W', 'TH', 'ST', 'E', 'N', '350? OR 39', '4099 N HWY', '?')) \
or row[3] in ('CEMETARY R', 'GUN CLUB R', 'JANET', 'WILSON ST'):
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[3]}', [])
addressErrors.extend(['bad address number', row[12]])
#---------------------------
if row[3] not in errorList and row[5] not in errorList:
if row[3].startswith('#') or row[2][0] == '#':
continue
elif '#' in row[3]:
addNum = row[3].split()[0]
unitID = row[3].split()
elif len(row[3]) <= 5:
if row[3].isalpha():
continue
if row[3][-1] == 'E':
continue
addNum = row[3].strip('W').strip()
else:
continue
if '.5' in addNum:
addNumSuf = '1/2'
addNum = re.sub('.5', '', addNum)
elif ' 1/2' in addNum:
addNumSuf = '1/2'
addNum = re.sub(' 1/2', '', addNum)
else:
addNumSuf = ''
preDir = returnKey(row[4], dirs)
sName = row[5].upper().strip()
sType = checkWord(row[6], parse_address.sTypes)
sufDir = returnKey(row[7], dirs)
if sufDir != '' and sType != '':
sType = ''
if sName[-2:] in sNameSuffs:
sName = sName[:-2]
if sName.isdigit() == True:
sufDir = row[5][-1:]
print (sufDir)
sType = ''
if sName.endswith((' AVE', ' DR', ' LN', ' RD', ' ST', ' STREET', ' WAY')):
sType = returnKey(sName.split()[-1], sTypeDir)
sName = ' '.join(sName.split()[:-1])
if sType == '' and row[2][-3:] in stripTypes:
sType = row[2][-3:].strip()
if sName.isdigit() == False and sType != '':
sufDir = ''
if sName == 'MAIN':
sType = 'ST'
if sName == '1777 S HWY 10':
sName = 'HWY 10'
if sName == 'HIGHWAY':
sName = 'HWY 6'
sType = ''
if sName in fix_types:
sType = returnKey(sName.split()[-1], sTypeDir)
sName = sName.strip(sName.split()[-1]).strip()
if sType == '' and sName.isdigit() == False and sName[0].isdigit() == False:
sType = returnKey(row[6], sTypeDir)
sufDir = ''
if sName == 'SCENIC VIEW':
sType = ''
if 'HIGHWAY 6' in row[2]:
sName = 'HWY 6'
if sType != '':
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[6]}', [])
addressErrors.extend(['street type not needed', row[12]])
sType = ''
if 'HWY' in sName:
sName = sName.lstrip('U S ')
if sType != '':
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[6]}', [])
addressErrors.extend(['street type not needed', row[12]])
sType = ''
hwyNumbers = ['6', '10', '96', '122', '123', '124', '157', '191', '264']
if row[5] in hwyNumbers and row[6] == 'HWY':
sName = f'HWY {row[5]}'
sType = ''
if row[6] != '' and row[6] != ' ' and row[6] != None and row[6] not in sTypeDir:
addressErrors = errorPtsDict.setdefault(f'{row[6]} | {row[2]}', [])
addressErrors.extend(['bad or missing street type', row[12]])
if row[9] not in errorList and row[9] != 'OFFICE':
building = str(row[9]).replace('.', '').strip()
else:
building = ''
unitType = returnKey(row[14], units)
if row[8] not in errorList:
unitID = row[8].strip('#')
if unitID.startswith(('STE', 'SUITE')):
unitType = 'STE'
unitID = row[8].split()[1].strip('#')
else:
unitID = ''
if unitType == 'UPPER':
unitType = ''
unitID = 'UPPR'
# cntyUnits = removeBadValues(str(row[8]).translate('.#'), errorList)
# if len(cntyUnits.split()) > 1:
# unitType = returnKey(cntyUnits.split()[0], units)
# unitID = cntyUnits.split()[1].replace('#', '')
# else:
# unitID = cntyUnits.replace('#', '')
# unitType = ''
if unitType == '' and unitID != '':
unitID_hash = f'# {unitID}'
fullAdd = f'{addNum} {addNumSuf} {preDir} {sName} {sType} {sufDir} {unitType} {unitID_hash}'
fullAdd = ' '.join(fullAdd.split())
else:
fullAdd = f'{addNum} {addNumSuf} {preDir} {sName} {sType} {sufDir} {unitType} {unitID}'
fullAdd = ' '.join(fullAdd.split())
elif row[2] != '' and row[2][0].isdigit() and len(row[2]) > 7:
address = parse_address.parse(row[2])
addNum = address.houseNumber
addNumSuf = ''
preDir = address.prefixDirection
if preDir == None:
preDir = ''
sName = address.streetName
sType = address.suffixType
if sType == None:
sType = ''
if sName == 'HIGHWAY 6':
sName = 'HWY 6'
sufDir = address.suffixDirection
if sufDir == None:
sufDir = ''
if sName == 'CENTRAL MILLER':
sName = 'CENTRAL MILLER CREEK'
sType = 'RD'
fullAdd = row[2].upper().replace('HIGHWAY 6', 'HWY 6')
fullAdd = ' '.join(fullAdd.split())
else:
continue
ptType = returnKey(row[1], ptTypeDict)
addSys = ''
utAddId = ''
city = ''
zip = ''
fips = '49007'
state = 'UT'
ptLocation = ''
structure = ''
landmark = removeBadValues(row[0], errorList)
parcel = row[10]
addSource = 'CARBON COUNTY'
loadDate = today
status = 'COMPLETE'
editor = ''
mod_date = row[11]
shp = row[12]
if row[5].upper() not in rdSet and row[5] != '' and 'HWY' not in sName:
addressErrors = errorPtsDict.setdefault(f'{row[2]} | {row[5]}', [])
addressErrors.extend(['street name not found in roads', row[12]])
if sName.endswith((' ALY', ' AVE', ' BAY', ' BND', ' BLVD', ' CYN', ' CTR', ' CIR', ' COR', ' CT', ' CV', \
' CRK', ' CRES', ' XING', ' DR', ' EST', ' ESTS', ' EXPY', ' FLT', ' FRK', ' FWY', \
' GLN', 'GRV', ' HTS', ' HWY', ' HL', ' HOLW', ' JCT', ' LN', ' LNDG', ' LOOP', \
' MNR', ' MDW', ' MDWS', ' PARK', ' PKWY', ' PASS', ' PL', ' PLZ', ' PT', ' RAMP', \
' RNCH', ' RDG', ' RD', ' RTE', ' ROW', ' RUN', ' SQ', ' ST', ' TER', ' TRCE', ' TRL', \
' VW', ' VLG', ' WAY')):
addressErrors = errorPtsDict.setdefault(f'{sName} | {row[2]}', [])
addressErrors.extend(['street type in name?', row[12]])
if sName.isdigit() and preDir in errorList and sufDir not in errorList:
continue
iCursor.insertRow((addSys, utAddId, fullAdd, addNum, addNumSuf, preDir, sName, sType, sufDir, landmark, building, \
unitType, unitID, city, zip, fips, state, ptLocation, ptType, structure, parcel, addSource, loadDate, \
status, editor, mod_date, '', '', '', shp))
#createErrorPts(errorPtsDict, cntyFldr, 'Carbon_ErrorPts.shp', 'EXAMPLE', carbonCoAddPts)
errorFlds = createErrorPts(errorPtsDict, cntyFldr, 'Carbon_ErrorPts.shp', 'EXAMPLE', carbonCoAddPts)
del iCursor
del sCursor_carbon
inputDict = {
'AddSystem':['SGID.LOCATION.AddressSystemQuadrants', 'GRID_NAME', ''],
'City':['SGID.BOUNDARIES.Municipalities', 'SHORTDESC', ''],
'ZipCode':['SGID.BOUNDARIES.ZipCodes', 'ZIP5', ''],
'USNG':['SGID.INDICES.NationalGrid', 'USNG', '']
}
addPolyAttributes(sgid, agrcAddPts_carbonCo, inputDict)
updateAddPtID(agrcAddPts_carbonCo)
addBaseAddress(agrcAddPts_carbonCo)
deleteDuplicatePts(agrcAddPts_carbonCo, ['UTAddPtID', 'SHAPE@WKT', 'OBJECTID'])
dupePts = returnDuplicateAddresses(agrcAddPts_carbonCo, ['UTAddPtID', 'SHAPE@'])
updateErrorPts(os.path.join(cntyFldr, 'Carbon_ErrorPts.shp'), errorFlds, dupePts)
def daggettCounty():
daggettCoAddPts = r'..\Daggett\DaggettCounty.gdb\DaggettAddress2021'
agrcAddPts_daggettCo = r'..\Daggett\Daggett.gdb\AddressPoints_Daggett'
cntyFldr = r'..\Daggett'
daggettCoAddFLDS = ['HouseAddr', 'HouseNum', 'PreDir', 'StreetName', 'StreetType', 'SufDir', 'UnitNumber',\
'Parcel_ID', 'Structure','Modified', 'SHAPE@', 'FullAddr']
aveDict = {'FIRST': '1ST', 'SECOND': '2ND', 'THIRD': '3RD', 'FOURTH': '4TH', 'FIFTH': '5TH', 'SIXTH': '6TH', \
'SEVENTH': '7TH', 'EIGHTH': '8TH', 'NINTH': '9TH', 'TENTH': '10TH', 'ELEVENTH': '11TH',
'TWELFTH': '12TH', 'THIRTEENTH': '13TH'}
aveList = {'1ST', '2ND', '3RD', '4TH', '5TH', '6TH', '7TH', '8TH', '9TH'}
checkRequiredFields(daggettCoAddPts, daggettCoAddFLDS)
truncateOldCountyPts(agrcAddPts_daggettCo)
daggettDirs = ('N', 'S', 'E', 'W', '')
fix_name = {'UTCH JOHN MTN':'DUTCH JOHN MTN', 'VALLEY VEW':'VALLEY VIEW'}
remove_type = ('LINWOOD LN', 'STATELINE RD')