hello python hero and legends. i have more then 23 routes generated by using network analyst. later on, i have converted the route into point shapefile. new formed point shapefile have many hundred of points for each routes. i have created a new column and i want to populate that column with sequential numbers for each point. a python script is available for such calculation but this scripts generates sequential number starting from 1st point to last one regardless the route class. i am looking for some advance calculation. i want sequential numbering for each route in new column. likeroute type seq.no1 point 11 point 21 point 31 point 42 point 12 point 22 point 3. ... so on.i need all this is a single python script.looking forward your great contribution.Nadeem Fareed
recDict = {} def autoIncrement(RID): global recDict pStart = 1 # adjust start value, if required pInterval = 1 # adjust interval value, if required if RID in recDict: recDict[RID] = recDict[RID] + pInterval else: recDict[RID] = pStart return recDict[RID]
dear sir see the attachment for detail. its not working.
hello everyonethe script given in response to my post by rfairhur24is not working well i tried it many ways i request rfairhur24, please try it and then send me back. i try hard to get job done with this script but its not working. i also request the other user or expert to please do me favor and just post something different and new for this task. i also request rfairhur24 please provide me stand alone python script that can work like a tool, any thing that could work batter. there is another option that i haveeach route have single unique ID named CID.for every route CID is different like for route no 1. points CID is 1, for route no.2 CID is 2 same is true for 23 routes.i am looking for a scripts that generate the sequential ID for each CID.best regardsNadeem Fareed
recDict = {} def autoIncrement(CID): global recDict pStart = 1 # adjust start value, if required pInterval = 1 # adjust interval value, if required if not CID: CID = "Null" if CID in recDict: recDict[CID] = recDict[CID] + pInterval else: recDict[CID] = pStart return recDict[CID]
dear rfairhur24. i have some issues with script you have provided to me, now, its ok with arcgis 10 version but its giving error in 10.1 version. arcgis 10 have python version 2.6.5 while arcgis 10.1 have python version 2.7.2. so script in python 2.7.2 version show some error in script like indent error like somethin. please could you fix the compatibility errors please. i try my hard to do this but i am not hero of python like you.thanks for response
# Import the arcpy module import arcpy pStart = 1 # adjust start value, if required pInterval = 1 # adjust interval value, if required # Initialize the sequence number dictionary and the Route ID variables seqDict = {} CID = "" # Assign data and field list variables. # Customize these variable inputs for your specific data myData = r"C:\MyPath\MyData.shp" fields = ["CID", "SEQUENCE", "GREATEST"] # Step 1 - Use an update cursor to assign Sequence numbers rows = arcpy.da.UpdateCursor(myData, fields) for row in rows: if row[0] is None: CID = "Null" else: CID = row[0] if CID in seqDict: seqDict[CID] = seqDict[CID] + pInterval else: seqDict[CID] = pStart row[1] = seqDict[CID] rows.updateRow(row) del row del rows # Step 2 - Use an update cursor to assign the Greatest Value to all records rows = arcpy.da.UpdateCursor(myData, fields) for row in rows: if row[0] is None: CID = "Null" else: CID = row[0] row[2] = seqDict[CID] rows.updateRow(row) del row del rows
just to be clear, my code was built with Service Pack 2 for ArcMap 10.1, so make sure you have installed Service Pack 2.
Service pack 2? Did I miss a memo?
Membros conectados podem postar, seguir atualizações e mais. Novo aqui? Registre uma conta gratuita.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.