Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import arcpy
- island_list =['island 1','island 2']#change to your list of islands
- def letter_code(x):
- if ord(x)>89:
- return chr(65)
- else:
- return chr(ord(x)+1)
- done = 'yes'
- x='ZZ'
- for isl in island_list:
- if done=='yes':
- qry = "island = '"+isl+"'" #change "island" to your field name
- arcpy.SelectLayerByAttribute_management("your_shp","NEW_SELECTION",qry)**#change your_shp to your shape file name**
- cur = arcpy.UpdateCursor("your_shp")#change your_shp to your shapefile name
- done='no'
- for row in cur:
- if x[1]=='Z':
- x=letter_code(x[0])+letter_code(x[1])
- else:
- x=x[0]+letter_code(x[1])
- print x
- row.code=x#letter_code(chr(x+i))+letter_code(chr(x+i+1))#change "row.code" to row.your field name where you want your letter combinations
- cur.updateRow(row)
- done = 'yes'
Add Comment
Please, Sign In to add comment