I'm trying to extend lines grouped by same value inside column.
So what i want to do is extend lines for each line with same WireID only. So for example lines with WireID 2 should all be extened to each other but not extended to lines with WireID 20.
I am trying to do it with grouping script
import itertools, arcpy def getGrouper(row): """Key function to retrieve Field value. Change depending on how you group""" return row def getDate(row): """Key function to retrieve Date value. Used in mapping function below""" return row def mostRecentDate(group): """Mapping function for retrieving row in each group with most recent date""" return max(group, key=getDate) # I define up here to avoid hard coding into body of script fc = "YourFeatureClass" # Column order is important, so define the field names outside cursor definitions fields = ["Field","Date","Flagged_Field"] #also putting the index of the flagged field up here, instead of hardcoding flagindex = 2 # groups is used to store the grouped records for further operations groups =  # Set search cursor with arcpy.da.SearchCursor(fc, fields) as cursor: # use itertools.groupby to group by Field and then append the results to groups for k, g in itertools.groupby(cursor, getGrouper): #I do nothing with the key, k, since you only care about the groups, not what they grouped on groups.append(list(g)) # At this point you have your groups # The rest is to do your example of flagging the most recent date # map groups to the most recent record in each group flaggedrecords = map(mostRecentDate, groups) # update records with arcpy.da.UpdateCursor(fc, fields) as cursor: for row in cursor: # Very important to tuple the update row, or else you will not have a match if tuple(row) in flaggedrecords: # If it is in the flagged records, set the flag row[flagindex] = 'Y' else: # Else, unset the flag row[flagindex] = '' cursor.updateRow(row)
I came up with idea that if i calculate bearing and then add 180 to it i can use it to create extended lines. Using bearing distance to line with bearing field and new distance field (with for example 2m distance) on End_X, End_Y column will create correct extended lines. If i do the same think using 'bearing+180' field, new distance on Start_X, Start_Y column i will get other extended lines.
My logic is if i group by WireID i can start a loop that use bearing distance to line, creates intersection point and then recreate my lines using new intersection points for each WireID separately. But first i don't know how to code it and secondly is it even possible?
I am working on ArcGIS Pro Basic Licence version 1.3. Can you help me?