How about something like this: ***untested code***import arcpy myFC = r"C:\temp\test.shp" yearField = "YEAR" countyField = "COUNTY_CD" sequenceField = "SEQUENCE" #Integer concatField = "CONCAT" #text of sufficient length trackingDict = {} updateRows = arcpy.UpdateCursor(myFC) for updateRow in updateRows: yearValue = updateRow.getValue(yearField) countyValue = updateRow.getValue(countyField) if (yearValue, countyValue) in trackingDict: trackingDict[(yearValue, countyValue)] = trackingDict[(yearValue, countyValue)] + 1 else: trackingDict[(yearValue, countyValue)] = 1 sequenceId = trackingDict[(yearValue, countyValue)] updateRow.setValue(sequenceField, sequenceId) updateRow.setValue(concatField, str(yearValue) + "-" + str(countyValue) + "-" + str(sequenceId)) updateRows.updateRow(updateRow) del updateRow, updateRows
import arcpy myFC = r"C:\temp\test.shp" yearField = "YEAR" countyField = "COUNTY_CD" sequenceField = "SEQUENCE" #Integer concatField = "CONCAT" #text of sufficient length trackingDict = {} updateRows = arcpy.UpdateCursor(myFC) for updateRow in updateRows: yearValue = updateRow.getValue(yearField) countyValue = updateRow.getValue(countyField) if (yearValue, countyValue) in trackingDict: trackingDict[(yearValue, countyValue)] = trackingDict[(yearValue, countyValue)] + 1 else: trackingDict[(yearValue, countyValue)] = 1 sequenceId = trackingDict[(yearValue, countyValue)] updateRow.setValue(sequenceField, sequenceId) updateRow.setValue(concatField, str(yearValue) + "-" + str(countyValue) + "-" + str(sequenceId)) updateRows.updateRow(updateRow) del updateRow, updateRows
Greetings. I am working on a project trying to get sequential Plan ID numbers for polygons produced in different year and different counties. I am using the field "County" to derive my County ID number (it is a string) and a "Year" field to derive my year value (alos a string. The format I am looking for is:2012-401-12012-401-22012-401-32012-363-12012-363-22011-401-12011-401-2Any help that y'all could provide would be greatly appreciated.
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.