|
POST
|
Hi, Here is what I have for some of my print statements. 10017531 [27087, 27127, 27187, 27190, 27111, 27128]
10017532 [27088, 27154]
10017533 [27089, 27254, 27255]
10017534 [27090, 27332]
10017535 [27091, 27134, 27135]
10017536 [27092, 90968]
10017538 [27093, 27124, 90965, 27095, 27125, 27133]
10017541 [27094, 27100, 27101, 27103, 27105]
10017540 [27130, 27099, 90956, 27129, 90957, 90962]
10017539 [27096, 27126]
10017542 [27102] Here is a screenshot for one of the dirtier areas.
... View more
01-18-2022
05:43 AM
|
0
|
0
|
2407
|
|
POST
|
Hi, I have a script, which works up but does not output the result that I am looking for, where some shared values don't get assigned the unique ID. Some portion of lines are getting separate IDs despite having a shared common point. Here is the script that I have working thus far: import arcpy
import time
start_time = 'Process start time: {}'.format(time.strftime('%I:%M:%S'))
print (start_time)
#arcpy.env.overwriteOutput = True
#spointFc = r'*'
#LineFc = r'*'
spointFc = r'*'
LineFc = r'*'
workspace = r'*'
edit = arcpy.da.Editor(workspace)
# Gather fields for searching through
# and updating each feature class.
SelectspointFc_Fields = [field.name for field in arcpy.ListFields(spointFc) if field.name in ['OBJECTID', 'IsolationIDA', 'IsolationIDB']]
SelectLineFc_Fields = [field.name for field in arcpy.ListFields(LineFc) if field.name in ['OBJECTID', 'IsolationID']]
AddspointShape_Field = ['SHAPE@X'] # Set as last/or end of the list of fields
AddLineShape_Field = ['SHAPE@'] # Set as last/or end of the list of fields
spointFc_Fields = SelectspointFc_Fields + AddspointShape_Field
LineFc_Fields = SelectLineFc_Fields + AddLineShape_Field
# Define the update and search cursors for
# input features.
updatePoint = arcpy.da.UpdateCursor(spointFc, spointFc_Fields)
updateLines = arcpy.da.UpdateCursor(LineFc, LineFc_Fields)
searchpoints = arcpy.da.SearchCursor(spointFc, spointFc_Fields)
searchLines = arcpy.da.SearchCursor(LineFc, LineFc_Fields)
# Loop through the line feature class and
# update based on whether the IsolationID
# is null.
i = 10000000
Assigned_IDs = {}
assigned_uniqueIDs = []
LineValues = {}
IDValues = {}
shared_IDs = {}
UpdateIsolatedIDs_Lines = {}
valve_points = []
Non_valvePoints = []
ID_list = []
startloop = 'Starting point feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
# Loop through the point feature class
# to get the Object ID and the
# floating X coordinate of the
# point feature class.
with searchpoints as cursor:
for point in cursor:
Vpoint = float(point[-1])
#print (int(Vpoint))
if Vpoint not in valve_points:
valve_points.append(Vpoint)
del cursor
stoploop ='Finished point feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop)
startloop = 'Starting line feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
with searchLines as cursor:
for row in cursor:
# Loop through the line feature class to
# get the Object ID, starting and ending line
# coordinates. Extract only the floating X
# coordinates of the line features.
ID = row[0]
startpnt = row[2].firstPoint
start = float(startpnt.X)
endpnt = row[2].lastPoint
end = float(endpnt.X)
# Check if the ID is in the specified dictionary, then check
# if both the start and end of the line are in the specified
# list and assign as key and values to specified dictionary.
if ID not in UpdateIsolatedIDs_Lines:
if start in valve_points and end in valve_points:
UpdateIsolatedIDs_Lines[ID] = i
i += 1
# Check if the start of the line is in the specified list
# and assign key and values to specified dictionary.
elif start not in valve_points and end in valve_points:
IDValues[ID] = [start]
ID_list.append(ID)
# Check if the start of the line is in the specified dictionary
# and assign starting coordinate as key with ID as value.
# Update the values if the start of the line already exists
# as the key in dictionary.
if start not in LineValues:
LineValues[start] = [ID]
else:
update = LineValues[start] + [ID]
LineValues[start] = update
#print (ID, update)
# Check if the end of the line is in the specified list and set
# ID as key in dictionary with ending coordinate as the value.
elif start in valve_points and end not in valve_points:
IDValues[ID] = [end]
ID_list.append(ID)
# Check if the end of the line is not in the specified dictionary and
# assign ending coordinate as key with ID as value to specified dictionary.
if end not in LineValues:
LineValues[end] = [ID]
else:
# Update the values if the end coordinate of the line already
# exists in dictionary and update the same key in the dictionary.
#print (ID, update)
update = LineValues[end] + [ID]
LineValues[end] = update
else:
# Check if both the start and end of the line are in the specified dictionary
# and assign ID as key in with list of starting and ending coordinate as values.
# Then assign the starting and ending coordiates as keys with the line ID as
# the values.
if start not in LineValues and end not in LineValues:
ID_list.append(ID)
IDValues[ID] = [start, end]
LineValues[start] = [ID]
LineValues[end] = [ID]
# Check if the start of the line is in the specified dictionary and assign
# the ID as key with a list of starting and ending coordinate as value.
# Then assign the starting and ending coordinates as keys with the line ID as
# the values. Update the values if the end coordinate already exists in
# dictionary as the key in the dictionary.
elif start not in LineValues and end in LineValues:
ID_list.append(ID)
IDValues[ID] = [start, end]
LineValues[start] = [ID]
update = LineValues[end] + [ID]
LineValues[end] = update
#print (end, update)
# Check if the start of the line is in the specified dictionary and assign
# the ID as key with a list of starting and ending coordinate as value.
# Then assign the starting and ending coordinates as keys with the line ID as
# the values. Update the values if the start coordinate already exists in
# dictionary as the key in the dictionary.
elif start in LineValues and end not in LineValues:
ID_list.append(ID)
IDValues[ID] = [start, end]
LineValues[end] = [ID]
update = LineValues[start] + [ID]
LineValues[start] = update
#print (end, update)
else:
# Assign the starting and ending coordiates as keys with the line ID as
# the values. # Update the values if the start coordinate of the line
# already exists in the dictionary and the same key in the dictionary.
ID_list.append(ID)
IDValues[ID] = [start, end]
update = LineValues[start] + [ID]
LineValues[start] = update
update = LineValues[end] + [ID]
LineValues[end] = update
del cursor
stoploop = 'Finished line feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop)
startloop = 'Starting Compiling Main Update Dictionary At {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
for ID in ID_list:
#print ('{} is the Object ID of the line'.format(ID))
unassigned_IDs = []
# Check if the ID is not in UpdateIsolatedIDs_Lines dictionary. Then check if ID is a key in the IDValues dictionary.
# If the ID is a key in dictionary, loop through all values in the dictionary. Check if the values of that dictionary
# are keys in LineValues dictionary. Loop through those values and append all values that are not equal to the ID to the
# the unassigned_values list.
if ID not in UpdateIsolatedIDs_Lines:
if IDValues[ID]:
print ('{} is key in {} dictionary with floating {} X coordinates as values'.format(ID, 'IDValues',IDValues[ID]))
for end in IDValues[ID]:
if LineValues[end]:
print ('The floating {} is the key in {} dictionary with {} line IDs as values'.format(end, 'LineValues', LineValues[end]))
for x in LineValues[end]:
if x not in UpdateIsolatedIDs_Lines:
unassigned_IDs.append(x)
sorted_list = sorted(unassigned_IDs)
#print (ID, sorted_list)
first = sorted_list[0]
if len(sorted_list) > 1:
if first == ID and first not in UpdateIsolatedIDs_Lines:
UpdateIsolatedIDs_Lines[first] = i
print ('{} has been assigned {} as value.'.format(first, UpdateIsolatedIDs_Lines[first]))
i += 1
for x in sorted_list[1:]:
UpdateIsolatedIDs_Lines[x] = UpdateIsolatedIDs_Lines[first]
print ('{} has been assigned {} as value.'.format(x, UpdateIsolatedIDs_Lines[first]))
elif first in UpdateIsolatedIDs_Lines:
UpdateIsolatedIDs_Lines[ID] = UpdateIsolatedIDs_Lines[first]
for x in sorted_list[1:]:
UpdateIsolatedIDs_Lines[x] = UpdateIsolatedIDs_Lines[first]
print ('{} has been assigned {} as value.'.format(x, UpdateIsolatedIDs_Lines[first]))
else:
UpdateIsolatedIDs_Lines[ID] = i
print ('{} has been assigned {} as value.'.format(first, UpdateIsolatedIDs_Lines[first]))
i += 1
else:
print ('{} is already assigned {} as isolation ID.'.format(ID, UpdateIsolatedIDs_Lines[ID]))
if IDValues[ID]:
print ('{} is key in {} dictionary with floating {} X coordinates as values'.format(ID, 'IDValues',IDValues[ID]))
for end in IDValues[ID]:
if LineValues[end]:
print ('The floating {} is the key in {} dictionary with {} line IDs as values'.format(end, 'LineValues', LineValues[end]))
for x in LineValues[end]:
UpdateIsolatedIDs_Lines[x] = UpdateIsolatedIDs_Lines[ID]
print ('{} has been assigned {} as value.'.format(x, UpdateIsolatedIDs_Lines[ID]))
#print ('\n\n')
finishloop = 'Finished Compiling Main Update Dictionary At {}\n'.format(time.strftime('%I:%M:%S'))
print (finishloop)
AssignedID_checklist = {}
for OID, AssignedID in UpdateIsolatedIDs_Lines.items():
if AssignedID not in AssignedID_checklist:
AssignedID_checklist[AssignedID] = [OID]
else:
AssignedID_checklist[AssignedID] += [OID]
startloop_updating = 'Starting ID Line Updates at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_updating)
edit.startEditing(False, True)
edit.startOperation()
with updateLines as cursor:
for row in cursor:
if row[0] in UpdateIsolatedIDs_Lines:
IsolationID = UpdateIsolatedIDs_Lines[row[0]]
print (row)
print (IsolationID)
if IsolationID:
row[0] = row[0]
row[1] = IsolationID
row[2] = row[2]
updateLines.updateRow(row)
print (row)
print ('\n')
del cursor
edit.stopOperation()
edit.stopEditing(True)
finishloop_updating = 'Finished ID Line Updates at {}\n'.format(time.strftime('%I:%M:%S'))
print (finishloop_updating)
finish_time = 'Process finish time: {}'.format(time.strftime('%I:%M:%S'))
print (finish_time)
... View more
01-14-2022
05:48 AM
|
0
|
7
|
2466
|
|
POST
|
Hi, So I have been given a code from someone that I spoke with at the Esri UC last year. I haven't had the chance to put it into use yet but I am planning on it. I had some other things come up but I will post the code once I get it implemented.
... View more
01-07-2022
01:02 PM
|
2
|
0
|
915
|
|
POST
|
I am trying. For the most part, things seem to work . However, I am struggling a bit with the logic handling. For some reason, I either assign the wrong ID to the wrong group, assign two IDs to two separate groups when those groups should be one group, or skip something entirely.
... View more
12-17-2021
08:40 AM
|
0
|
0
|
1912
|
|
POST
|
Hi @Anonymous User, I reworked the script where instead of creating two sets of two dictionaries to try and iterate through, I combined all like dictionaries into two main dictionaries. The first of which is comprised of the ID as the key with the line ends as the value(s) and the other which is comprised of the line ends as the key and coinciding IDs as values. This is in addition to a list of IDs. Rather than looping through multiple dictionaries like I tried previously, instead I resorted to looping through a single list of IDs, indexing the keys and values, loop through values, and index those values as keys to find all correlating values. The modified script came really close, and it runs far more efficiently than what I had previously. The script before took roughly 4 hours to run, but this slight modification runs in roughly 15 minutes. Here is the slightly modified script: import arcpy
import time
start_time = 'Process start time: {}'.format(time.strftime('%I:%M:%S'))
print (start_time)
spointFc = r'*'
LineFc = r'*'
workspace = r'*'
edit = arcpy.da.Editor(workspace)
# Gather fields for searching through
# and updating each feature class.
SelectspointFc_Fields = [field.name for field in arcpy.ListFields(spointFc) if field.name in ['OBJECTID', 'IsolationIDA', 'IsolationIDB']]
SelectLineFc_Fields = [field.name for field in arcpy.ListFields(LineFc) if field.name in ['OBJECTID', 'IsolationID']]
AddspointShape_Field = ['SHAPE@X']
AddLineShape_Field = ['SHAPE@']
spointFc_Fields = SelectspointFc_Fields + AddspointShape_Field
LineFc_Fields = SelectLineFc_Fields + AddLineShape_Field
# Define the update and search cursors for
# input features.
updatePoint = arcpy.da.UpdateCursor(spointFc, spointFc_Fields)
updateLines = arcpy.da.UpdateCursor(LineFc, LineFc_Fields)
searchpoints = arcpy.da.SearchCursor(spointFc, spointFc_Fields)
searchLines = arcpy.da.SearchCursor(LineFc, LineFc_Fields)
# Loop through the line feature class and
# update based on whether the IsolationID
# is null.
i = 10000000
Assigned_IDs = {}
assigned_uniqueIDs = [i]
LineValues = {}
IDValues = {}
shared_IDs = {}
UpdateIsolatedIDs_Lines = {}
valve_points = []
Non_valvePoints = []
ID_list = []
startloop = 'Starting point feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
with searchpoints as cursor:
for point in searchpoints:
#Vpoint = [x for x in point[-1]]
Vpoint = float(point[-1])
#print (int(Vpoint))
if Vpoint not in valve_points:
valve_points.append(Vpoint)
del cursor
stoploop ='Finished point feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop)
startloop = 'Starting line feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
with searchLines as cursor:
for row in cursor:
ID = row[0]
startpnt = row[2].firstPoint # Capture floating start point of line.
start = float(startpnt.X) # Capture floating X coordinate of line.
endpnt = row[2].lastPoint # Capture floating end point of line.
end = float(endpnt.X) # Capture floating X coordinate of line.
if ID not in UpdateIsolatedIDs_Lines: # Check if ID is in the specified dictionary.
if start in valve_points and end in valve_points: # Check if both the start and end of the line are in the specified list.
UpdateIsolatedIDs_Lines[ID] = i # Assign key and values to specified dictionary.
i += 1 # Increment i by 1
assigned_uniqueIDs.append(i) # Append i to list of used unique IDs
elif start not in valve_points and end in valve_points: # Check if the start of the line is in the specified list.
IDValues[ID] = [start] # Assign key and values to specified dictionary.
ID_list.append(ID)
if start not in LineValues: # Check if the start of the line is in the specified dictionary.
LineValues[start] = [ID] # Assign starting coordinate as key with ID as value to specified dictionary.
else:
update = LineValues[start] + [ID] # Update the values if the start of the line already exists in dictionary.
LineValues[start] = update # Update the key of the line already in dictionary.
#print (ID, update)
elif start in valve_points and end not in valve_points: # Check if the end of the line is in the specified list.
IDValues[ID] = [end] # Set ID as key in specified dictionary with list of ending coordinate as values
ID_list.append(ID) # Append ID to specified list.
if end not in LineValues: # Check if the end of the line is not in the specified dictionary.
LineValues[end] = [ID] # Assign ending coordinate as key with ID as value to specified dictionary.
else:
update = LineValues[end] + [ID] # Update the values if the end coordinate of the line already exists in dictionary.
LineValues[end] = update # Update the key of the line already in dictionary.
#print (ID, update)
else:
if start not in LineValues and end not in LineValues: # Check if both the start and end of the line are in the specified dictionary.
ID_list.append(ID) # Append ID to specified list.
IDValues[ID] = [start, end] # Set ID as key in specified dictionary with list of starting and ending coordinate as values
LineValues[start] = [ID] # Assign starting coordinate as key with ID as value to specified dictionary.
LineValues[end] = [ID] # Assign ending coordinate as key with ID as value to specified dictionary.
elif start not in LineValues and end in LineValues: # Check if the start of the line is in the specified dictionary.
ID_list.append(ID)
IDValues[ID] = [start, end]
LineValues[start] = [ID]
update = LineValues[end] + [ID]
LineValues[end] = update
#print (end, update)
elif start in LineValues and end not in LineValues:
ID_list.append(ID)
IDValues[ID] = [start, end]
LineValues[end] = [ID]
update = LineValues[start] + [ID]
LineValues[start] = update
#print (end, update)
else:
ID_list.append(ID)
IDValues[ID] = [start, end]
update = LineValues[start] + [ID]
LineValues[start] = update
update = LineValues[end] + [ID]
LineValues[end] = update
del cursor
stoploop = 'Finished line feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop)
startloop = 'Starting Compiling Main Update Dictionary At {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
for ID in ID_list:
#print (ID)
needs_assigning = []
if IDValues[ID]:
#print ('{} is key in {} dictionary with {} as values'.format(ID, 'IDValues',IDValues[ID]))
for end in IDValues[ID]:
if LineValues[end]:
#print ('{} is key in {} dictionary with {} as values'.format(end, 'LineValues', LineValues[end]))
for x in LineValues[end]:
if x not in needs_assigning and x != ID:
needs_assigning.append(x)
shared_IDs[ID] = needs_assigning
print ('{} is unique list of unassigned values'.format(needs_assigning))
if ID == needs_assigning[0]:
if needs_assigning[0] not in UpdateIsolatedIDs_Lines:
UpdateIsolatedIDs_Lines[ID] = i
#print ('{} has {} assigned as the unique ID'.format(needs_assigning[0], i))
i += 1
if UpdateIsolatedIDs_Lines[ID]:
for assign in needs_assigning:
UpdateIsolatedIDs_Lines[assign] = UpdateIsolatedIDs_Lines[ID]
#print ('{} has been assigned {} as unique ID'.format(assign, UpdateIsolatedIDs_Lines[ID]))
print ('\n')
finishloop = 'Finished Compiling Main Update Dictionary At {}'.format(time.strftime('%I:%M:%S'))
print (finishloop)
startloop = 'Starting Reading Dictionary At {}'.format(time.strftime('%I:%M:%S'))
print (startloop)
Assigned_IDGroups = {}
for ID, Assigned_ID in UpdateIsolatedIDs_Lines.items():
#print ('{} is assigned {} as a common ID'.format(ID, Assigned_ID))
if Assigned_ID not in Assigned_IDGroups:
Assigned_IDGroups[Assigned_ID] = [ID]
else:
update = Assigned_IDGroups[Assigned_ID] + [ID]
Assigned_IDGroups[Assigned_ID] = update
for UniqueIDs, grouped_IDs in Assigned_IDGroups.items():
print ('{} is assigned to this {} group of IDs.'.format(UniqueIDs, grouped_IDs))
finishloop = 'Finished Group Assignment IDs Dictionary At {}'.format(time.strftime('%I:%M:%S'))
print (finishloop) This script gets me close to what I am trying to accomplish, but I will give your suggestion a try and see how that performs. There are a few instances that raised an issue with either values being skipped, not grouped fully, or grouped in another group with another ID assigned.
... View more
12-16-2021
11:50 AM
|
0
|
0
|
1917
|
|
POST
|
Hi @RhysLlewellyn, If you are looking to accomplish assigning unique values to component within the range of the main component, then a more suggested manner in which to accomplish this would be to use a counter. Simply put, a counter will automatically assign a unique incrementing value to each sub-compartment of the main compartment. So one of several ways to assign the unique sub-compartment values is: import arcpy
updates = {}
feature_class = #file location for the feature class
fields = # list of fields to which to update the feature class based on the compartment field and the sub-compartment field
with arcpy.da.UpdateCursor(feature_class, fields) as Main_Cursor: # update feature class
for row in Main_Cursor: # loop through the feature
if row[0] not in updates and row[1] is not None:
updates[row[0]] = row[1]
elif row[0] in updates and row[1] is None: # check if row[0] in updates dict
update_value = updates[row[0]] + 1 # acquire value from updates dict and increase by 1
updates[row[0]] = update_value # update key with updated value
row[0] = row[0] # assign row[0] same value as self
row[1] = updates[row[0]] # assign row[1] as updates value
Main_Cursor.updateRow(row) # update row
else:
updates[row[0]] = 0 # assign row[0] as key and 0 as value
row[0] = row[0] # assign row[0] same value as self
row[1] = updates[row[0]] # assign row[1] value of updates[row[0]]
Main_Cursor.updateRow(row) # update row
del Main_Cursor # del cursor What you would like to do would be a more complicated approach than simply using a counter.
... View more
12-13-2021
09:53 AM
|
0
|
1
|
1975
|
|
POST
|
Hi, I have been working on this python script for a good while. For the most part, I am able to get it to work on a smaller set of data. However, I have noticed that it takes an exceptionally long time to execute for the entire database. I am not sure if I wrote this in an efficient manner, but I am quite perplexed as to how long it takes. I have tried splitting up the dictionaries to simplify matters and to have smaller sections of code execute. I am hoping this will speed up the process a bit but at this point I have run out of options. import arcpy
import time
spointFc = r'*'
LineFc = r'*'
workspace = r'*'
edit = arcpy.da.Editor(workspace)
startloop_pointFC = 'Starting point feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_pointFC)
with searchpoints as cursor:
for point in searchpoints:
#Vpoint = [x for x in point[-1]]
Vpoint = int(point[-1])
#print (int(Vpoint))
valve_points.append(Vpoint)
del cursor
stoploop_pointFC ='Finished point feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop_pointFC)
startloop_lineFC = 'Starting line feature class at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_lineFC)
edit.startEditing(False, True)
edit.startOperation()
with updateLines as cursor:
for row in cursor:
ID = row[0]
startpnt = row[2].firstPoint
#start = [startpnt.X, startpnt.Y]
start = int(startpnt.X)
endpnt = row[2].lastPoint
#end = [endpnt.X, endpnt.Y]
end = int(endpnt.X)
start_end = [start, end]
# Check if start or end coordinates are shared
# with any of the point coordinates (X)
A = 0
B = 0
for valve in valve_points:
if start/valve == 1:
A += 1
elif end/valve == 1:
B += 1
#if start in valve_points and end in valve_points:
if A == 1 and B == 1:
#print (row)
row[0] = row[0]
row[1] = i
row[2] = row[2]
updateLines.updateRow(row)
#print (row)
i += 1
#elif start in valve_points and end not in valve_points:
if A == 1 and B == 0:
#if end not in NonValvePoints:
NonValvePoints.append(end)
LinesWithValve[ID] = end
#elif end in valve_points and start not in valve_points:
if A == 0 and B == 1:
#if start not in NonValvePoints:
NonValvePoints.append(start)
LinesWithValve[ID] = start
else:
# If neither start or end coordinates are
# in the list of non-point coordinates
C = 0
D = 0
for Nvalve in NonValvePoints:
if start/Nvalve == 1:
C += 1
elif end/Nvalve == 1:
D += 1
# Check if C and D change in vales.
# If C and/or D change values, add ID as
# key with line ends as assigned values
if C == 1 and D == 1:
LinesWithoutValve[ID] = start_end
elif C == 1 and D == 0:
NonValvePoints.append(end)
LinesWithoutValve[ID] = start_end
elif C == 0 and D == 1:
NonValvePoints.append(start)
LinesWithoutValve[ID] = start_end
else:
NonValvePoints + start_end
LinesWithoutValve[ID] = start_end
del cursor
edit.stopOperation()
edit.stopEditing(True)
stoploop_lineFC = 'Finished line feature class at {}\n'.format(time.strftime('%I:%M:%S'))
print (stoploop_lineFC)
startloop_nonvalves = 'Starting dictionary at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_nonvalves)
# Run through dictionary and run through same dictionary
# to find any coinciding values for lines without valves.
for init_ID, End in LinesWithoutValve.items():
CoincidingIDs = []
for other_ID, OtherEnd in LinesWithoutValve.items():
if init_ID != other_ID:
isMatch = [e for e in End if e in OtherEnd]
if isMatch:
CoincidingIDs.append(other_ID)
if CoincidingIDs:
SharedIDs[init_ID] = CoincidingIDs
#print (init_ID, CoincidingIDs)
# Run through dictionary and run through other dictionary
# to find any coinciding values for lines with valves.
for init_ID, End in LinesWithoutValve.items():
CoincidingIDs = []
for lv_ID, line_valveEnd in LinesWithValve.items():
for E in End:
if E == line_valveEnd:
CoincidingIDs.append(lv_ID)
if init_ID in SharedIDs:
shared_updates = SharedIDs[init_ID] + CoincidingIDs
SharedIDs[init_ID] = shared_updates
finishloop_dict = 'Finished dictionary at {}\n'.format(time.strftime('%I:%M:%S'))
print (finishloop_dict) If anyone can provide any advice or somehow show a more efficient way to construct this; I would be greatly appreciated. Thanks
... View more
12-10-2021
11:12 AM
|
0
|
4
|
1958
|
|
POST
|
Thanks @JohannesLindner, I hadn't used them to the degree that some people do. As a matter of fact, I mostly use them with a search cursor. I had noticed that most of my script was getting locked up for some reason and taking as long as several hours. I tried to see if freeing up and locks and emptying dictionaries and lists that I compiled to see if that would speed up the processing a bit. Thank you very much for informing me.
... View more
12-09-2021
12:18 PM
|
0
|
0
|
3708
|
|
POST
|
Hi, I have a very simple question in regards to the del cursor. I use it from time to time but I have not thought about it. When is the del cursor used? I have a sample script with a del cursor but I am not sure if I used it in the right manner. edit.startEditing(False, True)
edit.startOperation()
with updateLines as cursor:
for row in updateLines:
if row[0] in UpdateIsolatedIDs_Lines:
IsolationID = UpdateIsolatedIDs_Lines[row[0]]
print (row)
#print (IsolationID)
if IsolationID:
row[0] = row[0]
row[1] = IsolationID
row[2] = row[2]
updateLines.updateRow(row)
print (row)
print ('\n')
del cursor
edit.stopOperation()
edit.stopEditing(True) I am not sure if the del cursor is used properly but I just wanted to ask.
... View more
12-09-2021
06:51 AM
|
0
|
2
|
3750
|
|
POST
|
Hi @JohannesLindner, This is exactly what I was looking for. I could not figure out a more efficient way of doing this since the sample I posted is magnitudes smaller than the actual dictionary. I have been trying to figure out the best way of doing this but I just couldn't, despite trying every thinkable option. Also, I didn't think of using a counter for some reason. I simply thought of just using some random integer. I figured picking a random number from a large range of numbers would make it near impossible for a duplicate to occur. That was my reasoning for that even though a counter, as you suggested, would have been the better option.
... View more
12-03-2021
11:32 AM
|
0
|
0
|
4020
|
|
POST
|
One thing that stands out is you are trying to make a feature layer from a row. This is something you cannot do. Instead, there are a couple of ways you could do this (either by modelbuilder or python). If you want to do this using python, use this instead: for row in cursor: output_location = (folder path or file gdb location) country_name = row[0] arcpy.CreateFeatureclass_management(output_location, country_name, "POLYGON") Do this for every row and it should provide you with what you are trying to get at.
... View more
12-02-2021
06:25 PM
|
0
|
1
|
5107
|
|
POST
|
Since I picked a sample size that was from a much larger size, I set up the script to make an exception where if the value is not the key in the dictionary, then automatically locate it and determine the unique ID. The other exception is meant to identify whether the length of values is greater than one, and if those values as keys also have values with a length greater than one. For instance: If you look at the key for 1, there are two other IDs that are shared. If you look at the values in the list, there is a corresponding key. That key also has values that exist as keys. Basically, if the keys and their values are in common, then assign it a unique ID for all of those values.
... View more
12-02-2021
12:30 PM
|
0
|
0
|
4047
|
|
POST
|
Hi, I have been trying for the past couple of days to create a unique ID for all shared IDs. I have something close to it, but I keep running into issues in regards to either getting all of the shared values or end up with a unique ID for a single value. Each unique ID should have at least two values. I am not sure if I structured my script accordingly or if there is something that I missed. In any case, I would greatly appreciate if anyone could take a look and let me know if there is a more efficient what to script this. ## 1 [2, 23]
## 2 [1, 3]
## 3 [2, 37]
## 15 [18]
## 18 [15, 19]
## 19 [18, 22]
## 22 [19, 124]
## 23 [1, 115247]
## 37 [3, 115241]
## 43 [106]
## 46 [48, 49]
## 47 [48]
etc...
import random
sample_dict = {1: [2, 23], 2: [1, 3], 3: [2, 37], 15: [18], 18: [15, 19], 19: [18, 22], 22: [19, 124], 23: [1, 115247], 37: [3, 115241], 43: [106], 46: [48, 49], 47: [48], 48: [46, 47, 49], 49: [46, 48, 4918], 51: [52, 115685], 52: [51, 115691], 56: [57], 57: [56, 60], 60: [57, 64], 64: [60], 66: [68, 88530], 68: [66, 73], 71: [72, 75], 72: [71, 73], 73: [68, 72], 75: [71, 76], 76: [75], 79: [80, 102], 80: [79, 82], 82: [80, 83], 83: [82, 84], 84: [83], 89: [98, 115270], 97: [99], 98: [89, 99], 99: [97, 98], 100: [115660, 115662], 101: [98285], 102: [79, 103], 103: [102], 104: [105], 105: [104], 106: [43], 108: [116], 111: [100838], 112: [113], 113: [112, 114], 114: [113, 121], 115: [121, 100842], 116: [108, 117], 117: [116, 100829], 120: [100841, 115265], 121: [114, 115], 124: [22, 125], 125: [124, 131], 131: [125], 135: [136, 286], 136: [135, 137], 137: [136, 138], 138: [137, 188], 142: [143, 188], 143: [142, 144], 144: [143, 115200], 148: [149, 108526, 115191], 149: [148, 110917], 150: [110917, 115182], 153: [189, 115209], 158: [110901, 115214], 161: [115212], 162: [163, 115224], 163: [162, 164], 164: [163, 115228], 167: [170, 115229], 170: [167, 171], 171: [170, 177], 174: [177, 115238], 177: [171, 174], 178: [187], 179: [186, 187], 186: [179, 115248], 187: [178, 179], 188: [138, 142], 189: [153, 115185], 190: [218], 191: [223, 350], 194: [195], 195: [194, 196, 199], 196: [195, 199, 111145], 199: [195, 196], 206: [209, 374], 209: [206, 210], 210: [209, 213], 213: [210, 215], 214: [215, 111145], 215: [213, 214], 218: [190, 226], 219: [222, 226], 222: [219, 115254], 223: [191, 115253], 226: [218, 219], 227: [272, 96846], 240: [241, 96852], 241: [240, 247], 247: [241, 115167], 256: [257], 257: [256, 762], 258: [259, 92884], 259: [258, 260], 260: [259, 263], 262: [96828], 263: [260], 264: [285, 115178], 272: [227, 288], 273: [275, 288], 275: [273, 278], 278: [275, 115172], 279: [282, 115173], 282: [279, 81472], 283: [289, 81471], 285: [264, 286], 286: [135, 285], 288: [272, 273], 289: [283, 115174], 290: [291, 115133], 291: [290, 311], 293: [296], 296: [293, 299], 299: [296, 115151], 303: [304], 304: [303], 311: [291, 115131], 313: [115147], 318: [324, 328], 321: [323, 331], 322: [332], 323: [321, 324], 324: [318, 323], 325: [326], 326: [325, 327], 327: [326, 328], 328: [318, 327], 331: [321, 333], 332: [322, 333], 333: [331, 332], 338: [341, 353], 341: [338, 342], 342: [341, 343], 343: [342, 346], 344: [345, 352], 345: [344, 346], 346: [343, 345], 349: [350], 350: [191, 349], 351: [352, 115142], 352: [344, 351], 353: [338, 115146], 354: [355], 355: [354, 92883], 361: [392, 115646], 362: [115637], 365: [366, 380], 366: [365, 383], 367: [383, 104125], 368: [370, 100846], 370: [368, 401], 373: [400, 115257], 374: [206], 376: [115638, 115640], 380: [365], 383: [366, 367], 391: [114410, 115578], 392: [361, 115649], 396: [115652], 400: [373, 403], 401: [370], 402: [104126, 114395], 403: [400, 104041], 406: [407, 6425], 407: [406, 6425, 82190], 409: [485, 98269], 410: [115276, 115278], 414: [415], 415: [414, 115678], 416: [417], 417: [416, 115274], 422: [423], 423: [422, 478], 424: [477], 431: [434], 434: [431, 450], 435: [13870, 115670], 440: [443], 443: [440], 446: [447, 481], 447: [446, 483], 450: [434, 451], 451: [450, 94393], 453: [486], 454: [484], 457: [458, 476], 458: [457, 461], 461: [458], 465: [468, 93441], 468: [465, 100879], 469: [93445, 115277], 474: [115281], 475: [476, 115282], 476: [457, 475], 477: [424, 478], 478: [423, 477], 481: [446, 100871], 483: [447], 484: [454, 485], 485: [409, 484], 486: [453, 115671], 489: [490], 490: [489, 491], 491: [490, 115290], 498: [115292, 115295], 499: [500, 115296], 500: [499, 503], 503: [500, 504], 504: [503, 507], 507: [504, 508], 508: [507, 511], 511: [508, 115298], 512: [115298, 115299], 517: [524, 115285], 520: [526], 524: [517], 526: [520, 529], 529: [526, 530], 530: [529, 531], 531: [530, 532], 532: [531], 539: [545], 542: [543, 549], 543: [542], 545: [539], 548: [76885, 93433], 549: [542, 552], 552: [549, 553], 553: [552], 554: [580, 598], 556: [595, 615], 564: [624, 115326], 567: [7675], 568: [609, 90917], 571: [574, 577, 114453], 574: [571], 577: [571, 578, 114453], 578: [577, 600], 579: [115312, 115313], 580: [554, 115315], 581: [113797, 115312], 584: [585, 587], 585: [584], 587: [584], 590: [115322], 591: [615], 595: [556, 648], 598: [554, 601], 600: [578], 601: [598, 115320], 609: [568], 613: [614, 664], 614: [613, 115334], 615: [556, 591], 617: [7560, 91525], 620: [634], 623: [699, 115511], 624: [564], 633: [634, 635], 634: [620, 633], 635: [633], 636: [637, 115512], 637: [636, 115517], 646: [647], 647: [646, 115516], 648: [595, 653], 651: [652], 652: [651, 653], 653: [648, 652], 656: [657, 719], 657: [656, 722], 660: [678], 663: [664, 677], 664: [613, 663], 665: [666, 682], 666: [665, 667], 667: [666, 668], 668: [667, 680], 669: [670, 679, 92570], 670: [669, 671, 92570], 671: [670, 672], 672: [671, 673], 673: [672, 674], 674: [673, 676], 675: [676, 687], 676: [674, 675], 677: [663, 678], 678: [660, 677], 679: [669, 680], 680: [668, 679], 681: [682, 93009], 682: [665, 681], 683: [93010], 684: [115337], 685: [115337], 686: [687, 1718], 687: [675, 686], 688: [700], 693: [698, 724], 698: [693], 699: [623, 700], 700: [688, 699], 705: [708], 708: [705, 711], 711: [708, 712], 712: [711, 715], 715: [712, 718], 718: [715, 719], 719: [656, 718], 722: [657, 723], 723: [722, 725], 724: [693, 725], 725: [723, 724], 728: [1793, 115497], 731: [734, 115501], 734: [731, 735], 735: [734, 738], 738: [735, 741], 741: [738, 115506], 743: [1315, 114885], 750: [84687], 762: [257, 765], 765: [762], 768: [769], 769: [768, 115164], 776: [780], 780: [776, 115163], 782: [783, 115165], 783: [782], 798: [799, 850], 799: [798, 845], 800: [806, 115022], 803: [804, 37270, 37279], 804: [803, 805, 37279], 805: [804, 115096], 806: [800, 115018], 841: [854, 115081], 844: [115075, 115079], 845: [799, 115071], 850: [798, 115070], 851: [866, 115078], 854: [841, 865], 855: [78696, 115089], 856: [115066, 115069], 859: [115067], 865: [854, 866], 866: [851, 865], 872: [874, 877], 873: [874, 895], 874: [872, 873], 875: [876], 876: [875, 877], 877: [872, 876], 880: [881, 1038], 881: [880, 884], 884: [881, 80306], 889: [891, 892], 890: [891, 918], 891: [889, 890, 892], 892: [889, 891, 922], 895: [873, 896], 896: [895, 899], 899: [896, 900], 900: [899], 905: [906, 103228], 906: [905, 927, 103228], 909: [925], 917: [926], 918: [890], 922: [892], 925: [909, 941], 926: [917], 927: [906], 936: [939, 104317], 939: [936, 940], 940: [939, 941], 941: [925, 940], 946: [953, 1045], 952: [953], 953: [946, 952, 1045], 957: [958, 115034], 958: [957], 961: [995, 1044], 966: [972, 103248], 969: [972], 972: [966, 969], 976: [977], 977: [976], 981: [1522], 985: [986, 1043], 986: [985, 987], 987: [986, 993], 993: [987, 994], 994: [993], 995: [961], 1001: [1002], 1002: [1001, 1005], 1005: [1002, 1006], 1006: [1005, 115038], 1007: [1013, 115038], 1013: [1007, 1014], 1014: [1013], 1019: [1023], 1023: [1019], 1025: [1028, 115042], 1028: [1025, 1031], 1031: [1028, 1035], 1035: [1031, 1036], 1036: [1035], 1037: [115047], 1038: [880, 115046], 1043: [985], 1044: [961, 8597, 103247], 1045: [946, 953, 1046], 1046: [1045], 1047: [1076, 107909], 1048: [1227, 1653], 1053: [1055], 1055: [1053], 1061: [88214], 1066: [79859], 1067: [1069, 1145], 1069: [1067, 1072], 1072: [1069, 1073], 1073: [1072, 1076], 1076: [1047, 1073], 1079: [1144], 1084: [1085, 1119], 1085: [1084], 1092: [1146], 1100: [1101], 1101: [1100, 1102], 1102: [1101, 1105], 1105: [1102], 1108: [1109], 1109: [1108, 1112], 1112: [1109, 1113], 1113: [1112, 1114], 1114: [1113], 1117: [1118], 1118: [1117, 1121], 1119: [1084, 1120], 1120: [1119, 1121], 1121: [1118, 1120], 1125: [1145], 1130: [1131, 1548], 1131: [1130, 1136], 1136: [1131, 1137], 1137: [1136, 1143], 1142: [90684, 115404], 1143: [1137, 1144], 1144: [1079, 1143], 1145: [1067, 1125], 1146: [1092], 1159: [1172, 97689], 1164: [97690], 1172: [1159], 1173: [115524], 1176: [114845], 1177: [1191, 114870], 1185: [1186], 1186: [1185, 1187], 1187: [1186, 96752], 1189: [1190, 1600], 1190: [1189], 1191: [1177, 1192], 1192: [1191, 1193], 1193: [1192, 1196], 1196: [1193, 1197], 1197: [1196, 114867], 1202: [114866], 1207: [1208], 1208: [1207, 1209], 1209: [1208, 114863], 1212: [114856, 114859], 1220: [1627, 1673], 1222: [1699], 1224: [1225, 1226], 1225: [1224], 1226: [1224, 1631], 1227: [1048, 1604], 1228: [1229, 1230], 1229: [1228, 114944], 1230: [1228, 1388, 114907], 1231: [1291], 1232: [1233], 1233: [1232, 1234], 1234: [1233, 1285], 1235: [1296, 1316], 1241: [1242, 114892], 1242: [1241, 1245], 1245: [1242, 1248], 1248: [1245, 1249], 1249: [1248, 1252], 1252: [1249, 1253], 1253: [1252, 1259], 1259: [1253, 1262], 1262: [1259], 1267: [1268], 1268: [1267, 1269], 1269: [1268, 1272], 1272: [1269, 1275], 1275: [1272, 1280], 1280: [1275], 1285: [1234, 1286], 1286: [1285, 114888], 1291: [1231, 1292], 1292: [1291, 1295], 1295: [1292, 1297], 1296: [1235, 1297], 1297: [1295, 1296], 1306: [1311, 1317], 1311: [1306, 1312], 1312: [1311, 1315], 1315: [743, 1312], 1316: [1235, 114887], 1317: [1306, 1318], 1318: [1317], 1319: [114954, 114959], 1320: [114934, 114936], 1321: [114933], 1325: [1328], 1328: [1325, 1329], 1329: [1328, 114931], 1332: [114928, 114930], 1335: [1337, 1339], 1337: [1335, 1338], 1338: [1337], 1339: [1335, 1340], 1340: [1339, 1343], 1343: [1340, 114940], 1346: [114941], 1349: [114939], 1353: [1356], 1356: [1353, 114936], 1361: [86809], 1362: [1363, 86810], 1363: [1362, 1364], 1364: [1363, 1365], 1365: [1364, 1366], 1366: [1365, 1367], 1367: [1366], 1371: [1372, 88556], 1372: [1371, 1373], 1373: [1372, 1376], 1374: [1375, 114928], 1375: [1374, 113162], 1376: [1373, 1377], 1377: [1376, 84160], 1378: [115739], 1379: [1383, 115738], 1380: [1381, 90369], 1381: [1380, 1382], 1382: [1381], 1383: [1379], 1385: [1388, 107390, 114911], 1388: [1230, 1385, 107390, 114907], 1391: [1401], 1394: [114906, 114923], 1401: [1391, 1404], 1404: [1401, 1407], 1407: [1404, 1408], 1408: [1407, 114814], 1409: [1410, 114821], 1410: [1409, 1413], 1413: [1410], 1419: [1420], 1420: [1419, 1421], 1421: [1420], 1425: [1533], 1426: [1525, 1551], 1427: [94100], 1432: [1434], 1434: [1432], 1440: [1525, 1526], 1443: [1444], 1444: [1443, 114882], 1452: [114881], 1455: [1456], 1456: [1455, 1457], 1457: [1456, 1460], 1460: [1457, 1531], 1463: [1464, 1531], 1464: [1463, 1465], 1465: [1464, 1468], 1468: [1465, 1472], 1472: [1468, 1473], 1473: [1472, 1476], 1476: [1473], 1483: [1484, 1487], 1484: [1483], 1487: [1483, 1490], 1490: [1487, 1491], 1491: [1490, 1492], 1492: [1491, 1495], 1495: [1492, 1496], 1496: [1495, 1499], 1499: [1496, 1500], 1500: [1499, 1529], 1505: [1528], 1510: [1515], 1515: [1510, 1518], 1518: [1515, 1519], 1519: [1518], 1522: [981], 1525: [1426, 1440], 1526: [1440, 47030], 1528: [1505, 1530], 1529: [1500, 1530], 1530: [1528, 1529], 1531: [1460, 1463], 1532: [86518], 1533: [1425, 1534], 1534: [1533, 1537], 1537: [1534, 1549], 1544: [1547], 1547: [1544, 1548], 1548: [1130, 1547], 1549: [1537], 1551: [1426, 1552], 1552: [1551, 1553], 1553: [1552, 1561], 1557: [1559, 1560], 1559: [1557, 80702], 1560: [1557, 98188], 1561: [1553, 114880], 1566: [1569, 114879], 1569: [1566, 102772], 1575: [102749, 114873], 1580: [1581], 1581: [1580, 1586], 1586: [1581, 114877]}
UpdateIsolatedIDs = {}
UIDs = {}
for A, B in sample_dict.items():
IsolationID = random.randint(10000000, 99999999)
#print (A, B)
try:
if A not in UpdateIsolatedIDs:
if len(B) > 1:
for b in B:
if b in sample_dict and b not in UpdateIsolatedIDs:
sample = sample_dict[b]
if A in sample:
if len(sample) > 1:
UpdateIsolatedIDs[A] = IsolationID
for s in sample:
if s != A:
UpdateIsolatedIDs[s] = UpdateIsolatedIDs[A]
UpdateIsolatedIDs[b] = UpdateIsolatedIDs[A]
except BLength:
if len(B) == 1:
sample = sample_dict[B[0]]
if len(sample) > 1:
if A in sample:
UpdateIsolatedIDs[A] = IsolationID
for s in sample:
if s != A and s not in UpdateIsolatedIDs:
UpdateIsolatedIDs[s] = UpdateIsolatedIDs[A]
UpdateIsolatedIDs[B[0]] = UpdateIsolatedIDs[A]
except b_sample_dict:
if b not in sample_dict and b not in UpdateIsolatedIDs:
if A in UpdateIsolatedIDs:
UpdateIsolatedIDs[b] = UpdateIsolatedIDs[A]
except sample_len:
if len(sample) == 1:
if A == sample:
if A not in UpdateIsolatedIDs:
UpdateIsolatedIDs[A] = IsolationID
except A_UpdateIsolatedIDs:
if A in UpdateIsolatedIDs:
for b in B:
if b not in UpdateIsolatedIDs:
UpdateIsolatedIDs[b] = UpdateIsolatedIDs[A]
for A, B in UpdateIsolatedIDs.items():
IsoID = []
for C, D in UpdateIsolatedIDs.items():
if B == D:
IsoID.append(C)
UIDs[B] = IsoID
for A, B in UIDs.items():
print (A, B)
... View more
12-02-2021
10:07 AM
|
0
|
4
|
4089
|
|
POST
|
Hi, I am trying to populate a field for lines that are separated by another point feature class. However, some lines shares common vertex coordinates but not with the point feature class. So the number of shared vertices can range anywhere from 2 - 5 lines. I have a script that generates a unique ID based on a random number, but what I am struggling with is how to go about it. I am also trying to keep it as light as possible without needing to create another feature class. Here is what I have thus far. (also, I keep getting the error message 'dictionary changed size during iteration' error message) import arcpy
import random
import time
start_time = 'Process start time: {}'.format(time.strftime('%I:%M:%S'))
print (start_time)
#arcpy.env.overwriteOutput = True
# Input parameters
#InputFolder = r'*'
spointFc = r'*'
LineFc = r'*'
# Describe input features
##desc = arcpy.Describe(LineFc)
##Geometry = desc.shapeType
# Create separate folder and database
#- Create folder if folder does not
#- exist.
##Folder_Name = 'Storage Folder'
##Folder = os.path.join(Folder_Name, InputFolder)
##
##Created_Folder = ''
##for root, directory, folders in os.walk(InputFolder):
## for folder in folders:
## if folder == Folder_Name:
## Created_Folder = os.path.join(folder, root)
## else:
## Created_Folder = os.mkdir(Folder_Location)
#- Create geodatabase if geodatabase does
#- not exist.
##Created_GDB_Name = 'DataHolding.gdb'
##Created_GDB = os.path.join(Created_GDB_Name, Created_Folder)
##
##Created_Geodatabase = ''
##for root, directory, folders in os.walk(Created_Folder):
## for folder in folders:
## if folder == Created_GDB_Name:
## Created_Geodatabase = os.path.join(folder, root)
## else:
## Created_Geodatabase = arcpy.CreateFileGDB_management(Created_Folder, Created_GDB_Name)
# Set newly created file geodatabase
# as the new workspace.
##arcpy.env.workspace = Created_Geodatabase
# Gather fields for searching through
# and updating each feature class.
SelectspointFc_Fields = [field.name for field in arcpy.ListFields(spointFc) if field.name in ['OBJECTID', 'IsolationIDA', 'IsolationIDB']]
SelectLineFc_Fields = [field.name for field in arcpy.ListFields(LineFc) if field.name in ['OBJECTID', 'IsolationID']]
AddspointShape_Field = ['SHAPE@XY']
AddLineShape_Field = ['SHAPE@']
spointFc_Fields = SelectspointFc_Fields + AddspointShape_Field
LineFc_Fields = SelectLineFc_Fields + AddLineShape_Field
# Define the update and search cursors for
# input features.
updatepoints = arcpy.da.UpdateCursor(spointFc, spointFc_Fields)
updateLines = arcpy.da.UpdateCursor(LineFc, LineFc_Fields)
searchpoints = arcpy.da.SearchCursor(spointFc, spointFc_Fields)
searchLines = arcpy.da.SearchCursor(LineFc, LineFc_Fields)
# Loop through the line feature class and
# update based on whether the IsolationID
# is null.
#LineID = {}
IsolatedIDs = {}
#SharedCounts = {}
UpdateIsolatedIDs = {}
valve_points = []
NoneValvePoints = []
startloop_pointFC = 'Starting point feature class loop at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_pointFC)
for point in searchpoints:
if point[-1] not in valve_points:
Vpoint = [x for x in point[-1]]
#print (Vpoint)
valve_points.append(Vpoint)
stoploop_pointFC ='Finished point feature class loop at {}'.format(time.strftime('%I:%M:%S'))
print (stoploop_pointFC)
startloop_lineFC = 'Starting line feature class loop at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_lineFC)
for line in searchLines:
i = 0
IsolationID = random.randint(10000000, 99999999)
ID = line[0]
startpnt = line[2].firstPoint
start = [startpnt.X, startpnt.Y]
endpnt = line[2].lastPoint
end = [endpnt.X, endpnt.Y]
start_end = [start, end]
UID = {ID: start_end}
if start in valve_points and end in valve_points:
UpdateIsolatedIDs[ID] = IsolationID
#print (IsolationID, ID)
elif start in valve_points and end not in valve_points:
if end not in NoneValvePoints:
NoneValvePoints.append(end)
elif end in valve_points and start not in valve_points:
if start not in NoneValvePoints:
NoneValvePoints.append(start)
else:
if start in NoneValvePoints and end in NoneValvePoints:
if IsolatedIDs:
for A, B in IsolatedIDs.items():
if start not in B and end not in B:
IsolatedIDs[IsolationID] = start_end
else:
IsolatedIDs[IsolationID] = start_end
print (IsolationID, start_end)
elif start in NoneValvePoints and end not in NoneValvePoints:
NoneValvePoints.append(end)
if IsolatedIDs:
for A, B in IsolatedIDs.items():
if start in B and end not in B:
update = B + [end]
IsolatedIDs[A] = update
elif start not in B and end in B:
update = B + [start]
IsolatedIDs[A] = update
else:
IsolatedIDs[IsolationID] = start_end
print (IsolationID, start_end)
elif end in NoneValvePoints and start not in NoneValvePoints:
NoneValvePoints.append(start)
if IsolatedIDs:
for A, B in IsolatedIDs.items():
if start in B and end not in B:
update = B + [end]
IsolatedIDs[A] = update
elif start not in B and end in B:
update = B + [start]
IsolatedIDs[A] = update
else:
IsolatedIDs[IsolationID] = start_end
print (IsolationID, start_end)
else:
NoneValvePoints + start_end
if IsolatedIDs:
for A, B in IsolatedIDs.items():
if start not in B and end not in B:
IsolatedIDs[IsolationID] = start_end
else:
IsolatedIDs[IsolationID] = start_end
print (IsolationID, start_end)
stoploop_lineFC = 'Finished line feature class loop at {}'.format(time.strftime('%I:%M:%S'))
print (stoploop_lineFC)
startloop_dict = 'Starting dictionary loop at {}'.format(time.strftime('%I:%M:%S'))
print (startloop_dict)
for A, B in IsolatedIDs.items():
print (A, B)
finishloop_dict = 'Finished dictionary loop at {}'.format(time.strftime('%I:%M:%S'))
print (finishloop_dict)
finish_time = 'Process finish time: {}'.format(time.strftime('%I:%M:%S'))
print (finish_time) I have also tried creating dictionaries within a single dictionary using the isolatedID as the key with another dictionary, created using the line ID and start and end vertices, as the value. Any help on this would be greatly appreciated. I will keep on trying but I have been struggling for quite some time with this.
... View more
11-29-2021
09:23 AM
|
0
|
0
|
821
|
|
IDEA
|
I have been thinking about this for quite some time, but I thought it would be very helpful if there was an application created specifically for scheduling either scripts, processes, field calculations, or updates to feature layers published either as hosted or from a server, where the user(s) can schedule tasks similar to windows task scheduler but as an Esri Application. I have noticed that there are a lot of people who need to understand programming or have certain permissions to utilize windows task scheduler. So I thought it would be a massive help if an online Esri application designed specifically to set scheduled tasks is something that could be created.
... View more
11-05-2021
05:09 AM
|
0
|
0
|
817
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 05-07-2026 01:36 PM | |
| 1 | 02-10-2026 06:09 AM | |
| 1 | 03-04-2026 01:08 PM | |
| 1 | 02-24-2026 12:59 PM | |
| 3 | 03-03-2026 10:33 AM |
| Online Status |
Offline
|
| Date Last Visited |
Monday
|