Skip to content

Commit df8bec8

Browse files
committed
Added a progress bar.
1 parent ba48225 commit df8bec8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

scripts/gp_open_location_geocode.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,14 @@ def generate_plus_code(feature_class, plus_code_field, code_length):
6969
# Validate the field is long enough to accomodate the code.
7070
validate_code_field_length(feature_class, plus_code_field, code_length)
7171

72-
count = 0
72+
# Get the number of features. This will be used to set a progress bar.
73+
count_features = int(arcpy.management.GetCount(feature_class)[0])
74+
arcpy.SetProgressor('step', 'Computing Plus Codes ...', 0, count_features, 1)
75+
7376
with arcpy.da.UpdateCursor(feature_class, ['SHAPE@XY', plus_code_field, 'OID@']) as input_cursor:
7477
for input_row in input_cursor:
7578

7679
oid = input_row[-1]
77-
count += 1
78-
79-
if count % 100000 == 0:
80-
arcpy.AddMessage('Processed {} rows so far ...'.format(count))
81-
8280
try:
8381
longitude = input_row[0][0]
8482
latitude = input_row[0][1]
@@ -89,6 +87,8 @@ def generate_plus_code(feature_class, plus_code_field, code_length):
8987
arcpy.AddWarning(
9088
'Something went wrong with feature OID: {} - Error Message: {}'.format(oid, ex.message)
9189
)
90+
finally:
91+
arcpy.SetProgressorPosition()
9292

9393

9494
if __name__ == '__main__':

0 commit comments

Comments
 (0)